mirror of
https://github.com/micropython/micropython.git
synced 2025-07-21 04:51:12 +02:00
rp2/mpnetworkport: Deregister all sys timeouts when netif is removed.
When mDNS is active on a netif it registers a lot of timeouts, namely: mdns_probe_and_announce mdns_handle_tc_question mdns_multicast_probe_timeout_reset_ipv4 mdns_multicast_timeout_25ttl_reset_ipv4 mdns_multicast_timeout_reset_ipv4 mdns_send_multicast_msg_delayed_ipv4 mdns_send_unicast_msg_delayed_ipv4 mdns_multicast_probe_timeout_reset_ipv6 mdns_multicast_timeout_25ttl_reset_ipv6 mdns_multicast_timeout_reset_ipv6 mdns_send_multicast_msg_delayed_ipv6 mdns_send_unicast_msg_delayed_ipv6 These may still be active after a netif is removed, and if they are called they will find that the mDNS state pointer in the netif is NULL and they will crash. These functions could be explicitly removed using `sys_untimeout()`, but `mdns_handle_tc_question()` is static so it's not possible to access it. Instead use the new `sys_untimeout_all_with_arg()` helper to deregister all timeout callbacks when a netif is removed. Fixes issue #17621. Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
|
||||
#if MICROPY_PY_LWIP
|
||||
|
||||
#include "extmod/modnetwork.h"
|
||||
#include "shared/runtime/softtimer.h"
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/timeouts.h"
|
||||
@@ -183,6 +184,10 @@ static void mp_network_netif_status_cb(struct netif *netif, netif_nsc_reason_t r
|
||||
mp_network_soft_timer.mode = SOFT_TIMER_MODE_PERIODIC;
|
||||
soft_timer_reinsert(&mp_network_soft_timer, LWIP_TICK_RATE_MS);
|
||||
}
|
||||
|
||||
if (reason == LWIP_NSC_NETIF_REMOVED) {
|
||||
sys_untimeout_all_with_arg(netif);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // MICROPY_PY_LWIP
|
||||
|
Reference in New Issue
Block a user