summaryrefslogtreecommitdiffstats
path: root/src/afb-session.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/afb-session.c')
-rw-r--r--src/afb-session.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/afb-session.c b/src/afb-session.c
index c63c6c46..1e3f5085 100644
--- a/src/afb-session.c
+++ b/src/afb-session.c
@@ -475,6 +475,7 @@ struct afb_session *afb_session_addref(struct afb_session *session)
{
if (session != NULL) {
afb_hook_session_addref(session);
+ session_lock(session);
session->refcount++;
session_unlock(session);
}
@@ -487,9 +488,9 @@ void afb_session_unref(struct afb_session *session)
if (session == NULL)
return;
- session_lock(session);
afb_hook_session_unref(session);
- if (--session->refcount) {
+ session_lock(session);
+ if (!--session->refcount) {
if (session->autoclose)
session_close(session);
if (session->notinset) {