OSDN Git Service

obexd: Fix disconnecting underline transport before processing operations
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Mon, 2 Sep 2013 08:13:40 +0000 (11:13 +0300)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Mon, 2 Sep 2013 10:29:43 +0000 (13:29 +0300)
The transport connection should only be dropped once all references to
the session are released otherwise some pending operations may not be
processed and the session will not be freed.

obexd/client/session.c

index 632e114..331d23d 100644 (file)
@@ -258,6 +258,12 @@ void obc_session_unref(struct obc_session *session)
        if (refs > 0)
                return;
 
+       /* Disconnect transport */
+       if (session->id > 0 && session->transport != NULL) {
+               session->transport->disconnect(session->id);
+               session->id = 0;
+       }
+
        session_free(session);
 }
 
@@ -555,12 +561,6 @@ void obc_session_shutdown(struct obc_session *session)
        if (session->path)
                session_unregistered(session);
 
-       /* Disconnect transport */
-       if (session->id > 0 && session->transport != NULL) {
-               session->transport->disconnect(session->id);
-               session->id = 0;
-       }
-
        obc_session_unref(session);
 }