mesh: Fix logic when cleaning up incomplete provisioning
authorInga Stotland <inga.stotland@intel.com>
Sat, 19 Jan 2019 06:53:18 +0000 (22:53 -0800)
committerAnupam Roy <anupam.r@samsung.com>
Tue, 17 Dec 2019 14:02:20 +0000 (19:32 +0530)
Do not call acceptor_cancel() if the provisioning has been completed,
either fail or success. Acceptor automatically takes care of cleanup
on completion, either successful or not.

mesh/mesh.c

index 9e927d2..cfdb490 100644 (file)
@@ -353,8 +353,6 @@ static void free_pending_join_call(bool failed)
                l_dbus_remove_watch(dbus_get_bus(),
                                                join_pending->disc_watch);
 
-       acceptor_cancel(&mesh);
-
        mesh_agent_remove(join_pending->agent);
 
        if (failed) {
@@ -374,11 +372,14 @@ void mesh_cleanup(void)
        mgmt_unref(mgmt_mesh);
 
        if (join_pending) {
-               /* The Join() call failed since it has not been completed */
-               reply = dbus_error(join_pending->msg, MESH_ERROR_FAILED,
+
+               if (join_pending->msg) {
+                       reply = dbus_error(join_pending->msg, MESH_ERROR_FAILED,
                                                        "Failed. Exiting");
-               l_dbus_send(dbus_get_bus(), reply);
+                       l_dbus_send(dbus_get_bus(), reply);
+               }
 
+               acceptor_cancel(&mesh);
                free_pending_join_call(true);
        }
 
@@ -427,6 +428,7 @@ static void prov_disc_cb(struct l_dbus *bus, void *user_data)
        if (join_pending->msg)
                l_dbus_message_unref(join_pending->msg);
 
+       acceptor_cancel(&mesh);
        join_pending->disc_watch = 0;
 
        free_pending_join_call(true);