Skip to contentSkip to conversation

mesh: Cancel unprovisioned scan on exit or app disconnect

PATCH Applied Inga Stotland 2 participants 2 messages Nov 12, 2019 – Nov 14, 2019 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

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
index 0b11b4541..adbb01280 100644
@@ -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
index f27ca4181..5a4c7d94a 100644
@@ -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
index e23f32dd1..d6dd819eb 100644
@@ -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
Applied
#1 lore raw

Applied

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
index 0b11b4541..adbb01280 100644
@@ -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
index f27ca4181..5a4c7d94a 100644
@@ -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
index e23f32dd1..d6dd819eb 100644
@@ -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);
 }