mesh: Create a queue of pending requests in mesh_init() 18/235118/1
authorInga Stotland <inga.stotland@intel.com>
Fri, 22 May 2020 00:34:57 +0000 (17:34 -0700)
committerAbhay Agarwal <ay.agarwal@samsung.com>
Thu, 28 May 2020 11:27:22 +0000 (16:57 +0530)
This removes unnnecessary checking for queue existence every time
either Attach(), Create() or Import() methods are called.

Change-Id: Icb85c67267594b9fa9f6a11c6f00a35eee8f9fc9
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
mesh/mesh.c

index 32540cc..b603d8b 100644 (file)
@@ -296,6 +296,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;
 }
 
@@ -651,9 +653,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,
@@ -759,10 +758,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,
@@ -850,11 +847,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,