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.
This commit is contained in:
Alex Villacís Lasso
2022-02-21 18:08:13 -05:00
parent 9f82a7ed3e
commit 350501ea4d

View File

@@ -593,9 +593,9 @@ void _tcpsock_dns_found(const char * name, struct ip_addr * ipaddr, void * arg)
}
// Updating state visible to asyncTcpSock task
xSemaphoreTakeRecursive(_asyncsock_mutex, (TickType_t)portMAX_DELAY);
// MUST NOT take _asyncsock_mutex lock, risks a deadlock if task holding lock
// attempts a LWIP network call.
c->_isdnsfinished = true;
xSemaphoreGiveRecursive(_asyncsock_mutex);
// TODO: actually use name
}