2019-11-12 06:23:07

by Stotland, Inga

[permalink] [raw]
Subject: [PATCH BlueZ] 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(+)

diff --git a/mesh/manager.c b/mesh/manager.c
index 0b11b4541..adbb01280 100644
--- a/mesh/manager.c
+++ b/mesh/manager.c
@@ -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);
+}
diff --git a/mesh/manager.h b/mesh/manager.h
index f27ca4181..5a4c7d94a 100644
--- a/mesh/manager.h
+++ b/mesh/manager.h
@@ -18,3 +18,4 @@
*/

bool manager_dbus_init(struct l_dbus *dbus);
+void manager_scan_cancel(struct mesh_node *node);
diff --git a/mesh/node.c b/mesh/node.c
index e23f32dd1..d6dd819eb 100644
--- a/mesh/node.c
+++ b/mesh/node.c
@@ -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);
}

--
2.21.0


2019-11-14 22:14:48

by Gix, Brian

[permalink] [raw]
Subject: Re: [PATCH BlueZ] mesh: Cancel unprovisioned scan on exit or app disconnect

Applied

On Mon, 2019-11-11 at 22:22 -0800, Inga Stotland wrote:
> 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(+)
>
> diff --git a/mesh/manager.c b/mesh/manager.c
> index 0b11b4541..adbb01280 100644
> --- a/mesh/manager.c
> +++ b/mesh/manager.c
> @@ -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);
> +}
> diff --git a/mesh/manager.h b/mesh/manager.h
> index f27ca4181..5a4c7d94a 100644
> --- a/mesh/manager.h
> +++ b/mesh/manager.h
> @@ -18,3 +18,4 @@
> */
>
> bool manager_dbus_init(struct l_dbus *dbus);
> +void manager_scan_cancel(struct mesh_node *node);
> diff --git a/mesh/node.c b/mesh/node.c
> index e23f32dd1..d6dd819eb 100644
> --- a/mesh/node.c
> +++ b/mesh/node.c
> @@ -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);
> }
>