diff options
| author | Felix Fietkau | 2025-05-12 09:15:09 +0000 |
|---|---|---|
| committer | Felix Fietkau | 2025-05-12 10:47:20 +0000 |
| commit | 6e60ce007bc3a7410aa1cf75256b9879cf10e25a (patch) | |
| tree | 701d05a0d990c04b20e4f8f113d46efc6a5f4c8e | |
| parent | 9bdbe24176ca32925e4aaa3f8650d5eb11fdfc5f (diff) | |
| download | openwrt-6e60ce007bc3a7410aa1cf75256b9879cf10e25a.tar.gz | |
unetmsg: clean up remote data when replacing the incoming connection
Ensure that pub/sub state is in sync
Signed-off-by: Felix Fietkau <nbd@nbd.name>
| -rw-r--r-- | package/network/services/unetmsg/files/usr/share/ucode/unetmsg/unetmsgd-remote.uc | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/package/network/services/unetmsg/files/usr/share/ucode/unetmsg/unetmsgd-remote.uc b/package/network/services/unetmsg/files/usr/share/ucode/unetmsg/unetmsgd-remote.uc index d905dbd349..65cdfac04a 100644 --- a/package/network/services/unetmsg/files/usr/share/ucode/unetmsg/unetmsgd-remote.uc +++ b/package/network/services/unetmsg/files/usr/share/ucode/unetmsg/unetmsgd-remote.uc @@ -46,6 +46,15 @@ function network_socket_close(data) data.socket.close(); } +function network_rx_cleanup_state(name) +{ + for (let name, sub in core.remote_subscribe) + delete sub[name]; + + for (let name, sub in core.remote_publish) + delete sub[name]; +} + function network_rx_socket_close(data) { if (!data) @@ -53,14 +62,10 @@ function network_rx_socket_close(data) core.dbg(`Incoming connection from ${data.name} closed\n`); let net = networks[data.network]; - if (net && net.rx_channels[data.name] == data) + if (net && net.rx_channels[data.name] != data) { delete net.rx_channels[data.name]; - - for (let name, sub in core.remote_subscribe) - delete sub[data.name]; - - for (let name, sub in core.remote_publish) - delete sub[data.name]; + network_rx_cleanup_state(data.name); + } network_socket_close(data); } @@ -189,6 +194,7 @@ function network_check_auth(sock_data, info) if (sock_data.timer) sock_data.timer.cancel(); sock_data.auth = true; + network_rx_cleanup_state(sock_data.name); net.rx_channels[sock_data.name] = sock_data; core.dbg(`Incoming connection from ${sock_data.name} established\n`); |