summaryrefslogtreecommitdiff
path: root/mesh/net.c
diff options
context:
space:
mode:
authorMichael N. Moran <mike@mnmoran.org>2020-11-06 17:48:11 -0500
committerBrian Gix <brian.gix@intel.com>2020-11-10 10:24:12 -0800
commit0b1247f07fbc4b9c368612c0fbcc5bb5a8fdbf1a (patch)
tree8113d1850f717357e9d421687958332e4204824c /mesh/net.c
parent11d4823fa011bd99ba13a4ec147b2ff223f4a86e (diff)
downloadbluez-0b1247f07fbc4b9c368612c0fbcc5bb5a8fdbf1a.tar.gz
mesh: Only deregister io for the last network detached
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.
Diffstat (limited to 'mesh/net.c')
-rw-r--r--mesh/net.c8
1 files 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);