mirror of
https://github.com/espressif/esp-protocols.git
synced 2025-07-16 12:02:11 +02:00
mdns: fix possible race condition when checking DHCP status on WIFI_EVENT_STA_CONNECTED event.
tcpip_adapter_dhcpc_get_status() returns the actual internal value of dhcp client without any locking or TCP/IP stack context call, so when CONNECTED event fired with default settings it started DHCP client in TCP/IP stack context and at the same time mdns event handler checking actual DHCP state, which could still be INIT (not STARTED). Purpose of this check is to enable PCB if DHCP was stopped before setting network interface up (typically static IP settings), so the solutin is to check against TCPIP_ADAPTER_DHCP_STOPPED state * Original commit: espressif/esp-idf@7f410a0bcb
This commit is contained in:
committed by
suren-gabrielyan-espressif
parent
7dfe14c83d
commit
f44c569422
@ -3062,7 +3062,7 @@ static void _mdns_handle_system_event(esp_event_base_t event_base,
|
|||||||
switch(event_id) {
|
switch(event_id) {
|
||||||
case WIFI_EVENT_STA_CONNECTED:
|
case WIFI_EVENT_STA_CONNECTED:
|
||||||
if (!tcpip_adapter_dhcpc_get_status(TCPIP_ADAPTER_IF_STA, &dcst)) {
|
if (!tcpip_adapter_dhcpc_get_status(TCPIP_ADAPTER_IF_STA, &dcst)) {
|
||||||
if (dcst != TCPIP_ADAPTER_DHCP_STARTED) {
|
if (dcst == TCPIP_ADAPTER_DHCP_STOPPED) {
|
||||||
_mdns_enable_pcb(TCPIP_ADAPTER_IF_STA, MDNS_IP_PROTOCOL_V4);
|
_mdns_enable_pcb(TCPIP_ADAPTER_IF_STA, MDNS_IP_PROTOCOL_V4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3085,7 +3085,7 @@ static void _mdns_handle_system_event(esp_event_base_t event_base,
|
|||||||
switch (event_id) {
|
switch (event_id) {
|
||||||
case ETHERNET_EVENT_CONNECTED:
|
case ETHERNET_EVENT_CONNECTED:
|
||||||
if (!tcpip_adapter_dhcpc_get_status(TCPIP_ADAPTER_IF_ETH, &dcst)) {
|
if (!tcpip_adapter_dhcpc_get_status(TCPIP_ADAPTER_IF_ETH, &dcst)) {
|
||||||
if (dcst != TCPIP_ADAPTER_DHCP_STARTED) {
|
if (dcst == TCPIP_ADAPTER_DHCP_STOPPED) {
|
||||||
_mdns_enable_pcb(TCPIP_ADAPTER_IF_ETH, MDNS_IP_PROTOCOL_V4);
|
_mdns_enable_pcb(TCPIP_ADAPTER_IF_ETH, MDNS_IP_PROTOCOL_V4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user