mesh: Only deregister io for the last network detached
authorMichael N. Moran <mike@mnmoran.org>
Fri, 6 Nov 2020 22:48:11 +0000 (17:48 -0500)
committerAbhay Agarwal <ay.agarwal@samsung.com>
Mon, 28 Dec 2020 06:20:04 +0000 (11:50 +0530)
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.

Change-Id: Iae00af608959dda15440801f2141602e1844e4aa
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
mesh/net.c

index 69b9f61..07c6e55 100644 (file)
@@ -2897,8 +2897,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);