diff mbox series

[BlueZ] mesh: Only deregister io for the last network detached

Message ID 20201106224811.1987610-1-mike@mnmoran.org
State New
Headers show
Series [BlueZ] mesh: Only deregister io for the last network detached | expand

Commit Message

Michael N. Moran Nov. 6, 2020, 10:48 p.m. UTC
When multiple mesh networks are active and one is detached
using Leave(), the I/O to all networks is halted.

This patch prevents that by only deregistering the I/O
if all networks have been detached.

---
 mesh/net.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Brian Gix Nov. 10, 2020, 6:26 p.m. UTC | #1
Applied

On Fri, 2020-11-06 at 17:48 -0500, Michael N. Moran wrote:
> When multiple mesh networks are active and one is detached

> using Leave(), the I/O to all networks is halted.

> 

> This patch prevents that by only deregistering the I/O

> if all networks have been detached.

> 

> ---

>  mesh/net.c | 8 ++++++--

>  1 file changed, 6 insertions(+), 2 deletions(-)

> 

> diff --git a/mesh/net.c b/mesh/net.c

> index 01a475d74..9e0ea860f 100644

> --- a/mesh/net.c

> +++ b/mesh/net.c

> @@ -2899,8 +2899,12 @@ struct mesh_io *mesh_net_detach(struct mesh_net *net)

>  	io = net->io;

>  

>  	mesh_io_send_cancel(net->io, &type, 1);

> -	mesh_io_deregister_recv_cb(io, snb, sizeof(snb));

> -	mesh_io_deregister_recv_cb(io, pkt, sizeof(pkt));

> +

> +	/* Only deregister io if this is the last network detached.*/

> +	if (l_queue_length(nets) < 2) {

> +		mesh_io_deregister_recv_cb(io, snb, sizeof(snb));

> +		mesh_io_deregister_recv_cb(io, pkt, sizeof(pkt));

> +	}

>  

>  	net->io = NULL;

>  	l_queue_remove(nets, net);
diff mbox series

Patch

diff --git a/mesh/net.c b/mesh/net.c
index 01a475d74..9e0ea860f 100644
--- a/mesh/net.c
+++ b/mesh/net.c
@@ -2899,8 +2899,12 @@  struct mesh_io *mesh_net_detach(struct mesh_net *net)
 	io = net->io;
 
 	mesh_io_send_cancel(net->io, &type, 1);
-	mesh_io_deregister_recv_cb(io, snb, sizeof(snb));
-	mesh_io_deregister_recv_cb(io, pkt, sizeof(pkt));
+
+	/* Only deregister io if this is the last network detached.*/
+	if (l_queue_length(nets) < 2) {
+		mesh_io_deregister_recv_cb(io, snb, sizeof(snb));
+		mesh_io_deregister_recv_cb(io, pkt, sizeof(pkt));
+	}
 
 	net->io = NULL;
 	l_queue_remove(nets, net);