diff options
author | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2014-03-21 13:49:38 +0200 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2014-03-21 16:13:45 +0200 |
commit | b35cdac7b1559c588ef393e3e9f8515a824e2a31 (patch) | |
tree | b625c6e4264bc5af94d25bddef03be85ead96e4d /obexd/client | |
parent | c78899a7898418dfa14d37bb249c783736018371 (diff) | |
download | bluez-b35cdac7b1559c588ef393e3e9f8515a824e2a31.tar.gz |
obexd/client: Fix not sending OBEX Disconnect when disconnecting
Sending OBEX Disconnect command before disconnecting the transport is
mandatory.
Diffstat (limited to 'obexd/client')
-rw-r--r-- | obexd/client/session.c | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/obexd/client/session.c b/obexd/client/session.c index 8138b1ecf..cb176e4ad 100644 --- a/obexd/client/session.c +++ b/obexd/client/session.c @@ -240,8 +240,6 @@ static void session_free(struct obc_session *session) if (session->p) pending_request_free(session->p); - sessions = g_slist_remove(sessions, session); - g_free(session->path); g_free(session->owner); g_free(session->source); @@ -250,6 +248,25 @@ static void session_free(struct obc_session *session) g_free(session); } +static void disconnect_complete(GObex *obex, GError *err, GObexPacket *rsp, + void *user_data) +{ + struct obc_session *session = user_data; + + DBG(""); + + if (err) + error("%s", err->message); + + /* Disconnect transport */ + if (session->id > 0 && session->transport != NULL) { + session->transport->disconnect(session->id); + session->id = 0; + } + + session_free(session); +} + void obc_session_unref(struct obc_session *session) { int refs; @@ -261,6 +278,19 @@ void obc_session_unref(struct obc_session *session) if (refs > 0) return; + sessions = g_slist_remove(sessions, session); + + if (!session->obex) + goto disconnect; + + /* Wait OBEX Disconnect to complete if command succeed otherwise + * proceed with transport disconnection since there is nothing else to + * be done */ + if (g_obex_disconnect(session->obex, disconnect_complete, session, + NULL)) + return; + +disconnect: /* Disconnect transport */ if (session->id > 0 && session->transport != NULL) { session->transport->disconnect(session->id); |