Skip to content
This repository was archived by the owner on Jan 20, 2025. It is now read-only.

Commit 350501e

Browse files
committed
Prevent deadlock between DNS resolution callback and LWIP call
Stop taking the _asyncsock_mutex when DNS resolution has finished. Doing so causes a deadlock because the callback runs in the LWIP thread and therefore will wait forever on the _asyncsock_mutex lock, but the task holding the lock can in turn attempt a LWIP call, which requires the LWIP thread to be runnable.
1 parent 9f82a7e commit 350501e

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/AsyncTCP.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,9 +593,9 @@ void _tcpsock_dns_found(const char * name, struct ip_addr * ipaddr, void * arg)
593593
}
594594

595595
// Updating state visible to asyncTcpSock task
596-
xSemaphoreTakeRecursive(_asyncsock_mutex, (TickType_t)portMAX_DELAY);
596+
// MUST NOT take _asyncsock_mutex lock, risks a deadlock if task holding lock
597+
// attempts a LWIP network call.
597598
c->_isdnsfinished = true;
598-
xSemaphoreGiveRecursive(_asyncsock_mutex);
599599

600600
// TODO: actually use name
601601
}

0 commit comments

Comments
 (0)