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);
--
2.26.2
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);