mesh: Cancel unprovisioned scan on exit or app disconnect
PATCH 1/1 mesh: Cancel unprovisioned scan on exit or app disconnect
If a provisioner app quits or the daemon is stopped while there's an active scan for unprovisioned devices in progress, the scan needs to be explicitly canceled.
--- mesh/manager.c | 8 ++++++++ mesh/manager.h | 1 + mesh/node.c | 10 ++++++++++ 3 files changed, 19 insertions(+)
mesh/manager.c +8 -0
@@ -794,3 +794,11 @@ bool manager_dbus_init(struct l_dbus *bus)return true; } + +void manager_scan_cancel (struct mesh_node *node) +{ +if (scan_node != node) +return ; + +scan_cancel (NULL , node); +}
mesh/manager.h +1 -0
@@ -18,3 +18,4 @@*/ bool manager_dbus_init (struct l_dbus *dbus); +void manager_scan_cancel (struct mesh_node *node);
mesh/node.c +10 -0
@@ -42,6 +42,7 @@#include "mesh/error.h" #include "mesh/dbus.h" #include "mesh/agent.h" +#include "mesh/manager.h" #include "mesh/node.h" #define MIN_COMP_SIZE 14
@@ -310,6 +311,10 @@ static void free_node_resources(void *data)l_queue_destroy (node->elements, element_free); node->elements =NULL ; +/* In case of a provisioner, stop active scanning */ +if (node->provisioner) +manager_scan_cancel (node); +free_node_dbus_resources (node);mesh_net_free (node->net);
@@ -1166,6 +1171,11 @@ static void app_disc_cb(struct l_dbus *bus, void *user_data)l_info ("App %s disconnected (%u)" , node->owner, node->disc_watch); node->disc_watch =0 ; + +/* In case of a provisioner, stop active scanning */ +if (node->provisioner) +manager_scan_cancel (node); +free_node_dbus_resources (node); }
Signature · 1 line
2.21.0
Gix, Brian
AppliedApplied
Quoted 69 lines · Inga Stotland
If a provisioner app quits or the daemon is stopped while there's an active scan for unprovisioned devices in progress, the scan needs to be explicitly canceled.
--- mesh/manager.c | 8 ++++++++ mesh/manager.h | 1 + mesh/node.c | 10 ++++++++++ 3 files changed, 19 insertions(+)mesh/manager.c +8
-0@@ -794,3 +794,11 @@ bool manager_dbus_init(struct l_dbus *bus)return true; } + +void manager_scan_cancel (struct mesh_node *node) +{ +if (scan_node != node) +return ; + +scan_cancel (NULL , node); +}mesh/manager.h +1
-0@@ -18,3 +18,4 @@*/ bool manager_dbus_init (struct l_dbus *dbus); +void manager_scan_cancel (struct mesh_node *node);mesh/node.c +10
-0@@ -42,6 +42,7 @@#include "mesh/error.h" #include "mesh/dbus.h" #include "mesh/agent.h" +#include "mesh/manager.h" #include "mesh/node.h" #define MIN_COMP_SIZE 14@@ -310,6 +311,10 @@ static void free_node_resources(void *data)l_queue_destroy (node->elements, element_free); node->elements =NULL ; +/* In case of a provisioner, stop active scanning */ +if (node->provisioner) +manager_scan_cancel (node); +free_node_dbus_resources (node);mesh_net_free (node->net);@@ -1166,6 +1171,11 @@ static void app_disc_cb(struct l_dbus *bus, void *user_data)l_info ("App %s disconnected (%u)" , node->owner, node->disc_watch); node->disc_watch =0 ; + +/* In case of a provisioner, stop active scanning */ +if (node->provisioner) +manager_scan_cancel (node); +free_node_dbus_resources (node); }