Skip to content

Commit 9509bdc

Browse files
committed
Compare task handles instead of opaque undocumented symbols
Based on commit 9b98550 of dumbfixes branch of 0xFEEDC0DE64 fork of ESPAsyncWebServer. The AsyncWebLock class tries to prevent self-deadlock by comparing the current task with the task currently holding the lock (if any). Use documented task handle values and APIs instead of grabbing undocumented external symbols for this.
1 parent a8840bc commit 9509bdc

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/AsyncWebSynchronization.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class AsyncWebLock
4444
{
4545
private:
4646
SemaphoreHandle_t _lock;
47-
mutable void *_lockedBy;
47+
mutable TaskHandle_t _lockedBy{};
4848

4949
public:
5050
AsyncWebLock() {
@@ -61,10 +61,10 @@ class AsyncWebLock
6161
}
6262

6363
bool lock() const {
64-
extern void *pxCurrentTCB;
65-
if (_lockedBy != pxCurrentTCB) {
64+
const auto currentTask = xTaskGetCurrentTaskHandle();
65+
if (_lockedBy != currentTask) {
6666
xSemaphoreTake(_lock, portMAX_DELAY);
67-
_lockedBy = pxCurrentTCB;
67+
_lockedBy = currentTask;
6868
return true;
6969
}
7070
return false;

0 commit comments

Comments
 (0)