From 4a276a4bfdfe6d8dea9f1fac9cc778212882e93f Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Mon, 20 Oct 2008 23:21:26 +0200 Subject: [PATCH] obexd: Call agent release method only if present --- obexd/client/session.c | 53 ++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/obexd/client/session.c b/obexd/client/session.c index 6c412bda8..66aec0081 100644 --- a/obexd/client/session.c +++ b/obexd/client/session.c @@ -65,7 +65,10 @@ static struct session_data *session_ref(struct session_data *session) static void session_unref(struct session_data *session) { - if (g_atomic_int_dec_and_test(&session->refcount) == TRUE) { + if (g_atomic_int_dec_and_test(&session->refcount) == FALSE) + return; + + if (session->agent_name != NULL) { DBusMessage *message; message = dbus_message_new_method_call(session->agent_name, @@ -74,38 +77,38 @@ static void session_unref(struct session_data *session) dbus_message_set_no_reply(message, TRUE); g_dbus_send_message(session->conn, message); + } - if (session->pending != NULL) - g_ptr_array_free(session->pending, TRUE); - - if (session->obex != NULL) { - if (session->xfer != NULL) { - gw_obex_xfer_close(session->xfer, NULL); - gw_obex_xfer_free(session->xfer); - } + if (session->pending != NULL) + g_ptr_array_free(session->pending, TRUE); - gw_obex_close(session->obex); + if (session->obex != NULL) { + if (session->xfer != NULL) { + gw_obex_xfer_close(session->xfer, NULL); + gw_obex_xfer_free(session->xfer); } - if (session->sock > 2) - close(session->sock); + gw_obex_close(session->obex); + } - if (session->conn) { - if (session->path) - g_dbus_unregister_interface(session->conn, - session->path, TRANSFER_INTERFACE); + if (session->sock > 2) + close(session->sock); - dbus_connection_unref(session->conn); - } + if (session->conn) { + if (session->path) + g_dbus_unregister_interface(session->conn, + session->path, TRANSFER_INTERFACE); - g_free(session->path); - g_free(session->name); - g_free(session->target); - g_free(session->filename); - g_free(session->agent_name); - g_free(session->agent_path); - g_free(session); + dbus_connection_unref(session->conn); } + + g_free(session->path); + g_free(session->name); + g_free(session->target); + g_free(session->filename); + g_free(session->agent_name); + g_free(session->agent_path); + g_free(session); } static gboolean rfcomm_callback(GIOChannel *io, GIOCondition cond, -- 2.47.3