aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2018-02-26 14:35:00 +0100
committerJosé Bollo <jose.bollo@iot.bzh>2018-02-26 14:40:37 +0100
commitfc460fb90672bc80d1f140a8f6cf72d7ad95353a (patch)
tree51edb860ffe945284b84620a5bfbddceaad83e93
parentafff776f7e27c8be7610cfbd23c4d1be32699ed9 (diff)
afb-session: Fix bugs
Change-Id: Ib45e2db47827b4527435a40c4b79d02fb3ab488a Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-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) {