Skip to content

Commit 9b3b41c

Browse files
mdns: fixed crashes on network changes
1) two events AP_STOP, AP_START shortly after each other may cause IGMP config on already stopped netif 2) not properly locked sending packets to queue from timer task closes #2580 * Original commit: espressif/esp-idf@097282a
1 parent ea23007 commit 9b3b41c

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

components/mdns/mdns.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3794,13 +3794,14 @@ static esp_err_t _mdns_send_search_action(mdns_action_type_t type, mdns_search_o
37943794
*/
37953795
static void _mdns_scheduler_run()
37963796
{
3797+
MDNS_SERVICE_LOCK();
37973798
mdns_tx_packet_t * p = _mdns_server->tx_queue_head;
37983799
mdns_action_t * action = NULL;
37993800

38003801
if (!p) {
3802+
MDNS_SERVICE_UNLOCK();
38013803
return;
38023804
}
3803-
MDNS_SERVICE_LOCK();
38043805
if ((int32_t)(p->send_at - (xTaskGetTickCount() * portTICK_PERIOD_MS)) < 0) {
38053806
action = (mdns_action_t *)malloc(sizeof(mdns_action_t));
38063807
if (action) {

components/mdns/mdns_networking.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ static esp_err_t _udp_join_group(tcpip_adapter_if_t tcpip_if, mdns_ip_protocol_t
6262
{
6363
struct netif * netif = NULL;
6464
void * nif = NULL;
65+
66+
if (!tcpip_adapter_is_netif_up(tcpip_if)) {
67+
// Network interface went down before event propagated, skipping IGMP config
68+
return ESP_ERR_INVALID_STATE;
69+
}
70+
6571
esp_err_t err = tcpip_adapter_get_netif(tcpip_if, &nif);
6672
if (err) {
6773
return ESP_ERR_INVALID_ARG;

0 commit comments

Comments
 (0)