diff --git a/obexd/client/session.c b/obexd/client/session.c
index f677bcb..2e8b113 100644
--- a/obexd/client/session.c
+++ b/obexd/client/session.c
struct obc_session *obc_session_ref(struct obc_session *session)
{
- g_atomic_int_inc(&session->refcount);
+ int refs = __sync_add_and_fetch(&session->refcount, 1);
- DBG("%p: ref=%d", session, session->refcount);
+ DBG("%p: ref=%d", session, refs);
return session;
}
void obc_session_unref(struct obc_session *session)
{
- gboolean ret;
+ int refs;
- ret = g_atomic_int_dec_and_test(&session->refcount);
+ refs = __sync_sub_and_fetch(&session->refcount, 1);
- DBG("%p: ref=%d", session, session->refcount);
+ DBG("%p: ref=%d", session, refs);
- if (ret == FALSE)
+ if (refs > 0)
return;
session_free(session);