diff options
author | José Bollo <jose.bollo@iot.bzh> | 2017-06-07 13:59:08 +0200 |
---|---|---|
committer | José Bollo <jose.bollo@iot.bzh> | 2017-06-07 13:59:08 +0200 |
commit | b192d4cc46d8bda166116432ee28042e95750052 (patch) | |
tree | f5261c6f5790d8d7dc21d36cc7aeea0f12fb1138 /src/afb-ws-json1.c | |
parent | 142f890314a2279a383a70251e1579f277c408e3 (diff) |
Fix concurrency issue in handling references
Change-Id: Iaae331fbdadb88f26057a64193a026950dcb56e4
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/afb-ws-json1.c')
-rw-r--r-- | src/afb-ws-json1.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/afb-ws-json1.c b/src/afb-ws-json1.c index 45e1cdb0..c796b17c 100644 --- a/src/afb-ws-json1.c +++ b/src/afb-ws-json1.c @@ -145,13 +145,13 @@ error: static struct afb_ws_json1 *aws_addref(struct afb_ws_json1 *ws) { - ws->refcount++; + __atomic_add_fetch(&ws->refcount, 1, __ATOMIC_RELAXED); return ws; } static void aws_unref(struct afb_ws_json1 *ws) { - if (--ws->refcount == 0) { + if (!__atomic_sub_fetch(&ws->refcount, 1, __ATOMIC_RELAXED)) { afb_evt_listener_unref(ws->listener); afb_wsj1_unref(ws->wsj1); if (ws->cleanup != NULL) |