linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Inga Stotland <inga.stotland@intel.com>
To: linux-bluetooth@vger.kernel.org
Cc: brian.gix@intel.com, johan.hedberg@gmail.com,
	luiz.dentz@gmail.com, Inga Stotland <inga.stotland@intel.com>
Subject: [PATCH BlueZ 1/2] mesh: Unreference pending D-Bus messages
Date: Tue, 21 May 2019 22:33:38 -0700	[thread overview]
Message-ID: <20190522053339.6289-2-inga.stotland@intel.com> (raw)
In-Reply-To: <20190522053339.6289-1-inga.stotland@intel.com>

This change results in proper cleanup of D-Bus messages for pending
replies: if l_dbus_message_ref() was called for a message, then
l_dbus_message_unref() must be called for the same message to completely
free the message resources.
---
 mesh/mesh.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/mesh/mesh.c b/mesh/mesh.c
index 231a6bca4..bed8484f2 100644
--- a/mesh/mesh.c
+++ b/mesh/mesh.c
@@ -354,6 +354,9 @@ static void free_pending_join_call(bool failed)
 
 	mesh_agent_remove(join_pending->agent);
 
+	if (join_pending->msg)
+		l_dbus_message_unref(join_pending->msg);
+
 	if (failed)
 		node_remove(join_pending->node);
 
@@ -422,9 +425,6 @@ static void prov_disc_cb(struct l_dbus *bus, void *user_data)
 	if (!join_pending)
 		return;
 
-	if (join_pending->msg)
-		l_dbus_message_unref(join_pending->msg);
-
 	acceptor_cancel(&mesh);
 	join_pending->disc_watch = 0;
 
@@ -650,6 +650,7 @@ static void attach_ready_cb(void *user_data, int status, struct mesh_node *node)
 
 done:
 	l_dbus_send(dbus_get_bus(), reply);
+	l_dbus_message_unref(pending_msg);
 	l_queue_remove(pending_queue, pending_msg);
 }
 
@@ -727,6 +728,7 @@ static void create_network_ready_cb(void *user_data, int status,
 
 done:
 	l_dbus_send(dbus_get_bus(), reply);
+	l_dbus_message_unref(pending_msg);
 	l_queue_remove(pending_queue, pending_msg);
 }
 
-- 
2.21.0


  reply	other threads:[~2019-05-22  5:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-22  5:33 [PATCH BlueZ 0/2] mesh: Clean up D-Bus message references Inga Stotland
2019-05-22  5:33 ` Inga Stotland [this message]
2019-05-22  5:33 ` [PATCH BlueZ 2/2] mesh: Remove unnecessary message ref/unref in agent.c Inga Stotland

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190522053339.6289-2-inga.stotland@intel.com \
    --to=inga.stotland@intel.com \
    --cc=brian.gix@intel.com \
    --cc=johan.hedberg@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).