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, Inga Stotland <inga.stotland@intel.com>
Subject: [PATCH BlueZ 06/10] mesh: Create a queue of pending requests in mesh_init()
Date: Thu, 21 May 2020 17:34:57 -0700	[thread overview]
Message-ID: <20200522003501.106165-7-inga.stotland@intel.com> (raw)
In-Reply-To: <20200522003501.106165-1-inga.stotland@intel.com>

This removes unnnecessary checking for queue existence every time
either Attach(), Create() or Import() methods are called.
---
 mesh/mesh.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/mesh/mesh.c b/mesh/mesh.c
index 8bd7b3978..4a3ba171d 100644
--- a/mesh/mesh.c
+++ b/mesh/mesh.c
@@ -297,6 +297,8 @@ bool mesh_init(const char *config_dir, const char *mesh_conf_fname,
 	mesh_io_get_caps(mesh.io, &caps);
 	mesh.max_filters = caps.max_num_filters;
 
+	pending_queue = l_queue_new();
+
 	return true;
 }
 
@@ -652,9 +654,6 @@ static struct l_dbus_message *attach_call(struct l_dbus *dbus,
 	sender = l_dbus_message_get_sender(msg);
 
 	pending_msg = l_dbus_message_ref(msg);
-	if (!pending_queue)
-		pending_queue = l_queue_new();
-
 	l_queue_push_tail(pending_queue, pending_msg);
 
 	status = node_attach(app_path, sender, token, attach_ready_cb,
@@ -760,10 +759,8 @@ static struct l_dbus_message *create_network_call(struct l_dbus *dbus,
 							"Bad device UUID");
 
 	sender = l_dbus_message_get_sender(msg);
-	pending_msg = l_dbus_message_ref(msg);
-	if (!pending_queue)
-		pending_queue = l_queue_new();
 
+	pending_msg = l_dbus_message_ref(msg);
 	l_queue_push_tail(pending_queue, pending_msg);
 
 	node_create(app_path, sender, uuid, create_node_ready_cb,
@@ -851,11 +848,8 @@ static struct l_dbus_message *import_call(struct l_dbus *dbus,
 							"Bad address");
 
 	sender = l_dbus_message_get_sender(msg);
-	pending_msg = l_dbus_message_ref(msg);
-
-	if (!pending_queue)
-		pending_queue = l_queue_new();
 
+	pending_msg = l_dbus_message_ref(msg);
 	l_queue_push_tail(pending_queue, pending_msg);
 
 	if (!node_import(app_path, sender, uuid, dev_key, net_key, net_idx,
-- 
2.26.2


  parent reply	other threads:[~2020-05-22  0:35 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-22  0:34 [PATCH BlueZ 00/10] Mesh code clean up Inga Stotland
2020-05-22  0:34 ` [PATCH BlueZ 01/10] mesh: Remove unused structure member Inga Stotland
2020-05-22  0:34 ` [PATCH BlueZ 02/10] mesh: Free allocated agent in mesh_remove_agent() Inga Stotland
2020-05-22  0:34 ` [PATCH BlueZ 03/10] mesh: Remove agent when freeing node's dynamic resources Inga Stotland
2020-05-22  0:34 ` [PATCH BlueZ 04/10] mesh: Add finalization of a newly created node Inga Stotland
2020-05-22  0:34 ` [PATCH BlueZ 05/10] mesh: Remove unused function prototypes from node.h Inga Stotland
2020-05-22  1:12   ` [BlueZ,05/10] " bluez.test.bot
2020-05-22  0:34 ` Inga Stotland [this message]
2020-05-22  0:34 ` [PATCH BlueZ 07/10] mesh: Clean up Import() method call Inga Stotland
2020-05-22  0:34 ` [PATCH BlueZ 08/10] mesh: Clean up Attach() " Inga Stotland
2020-05-22  0:35 ` [PATCH BlueZ 09/10] mesh: Fix memory leak in Create, Import & Attach methods Inga Stotland
2020-05-22  0:35 ` [PATCH BlueZ 10/10] mesh: Clean up Join() method Inga Stotland
2020-05-22 20:54 ` [PATCH BlueZ 00/10] Mesh code clean up Gix, Brian

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=20200522003501.106165-7-inga.stotland@intel.com \
    --to=inga.stotland@intel.com \
    --cc=brian.gix@intel.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /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).