mirror of
https://github.com/me-no-dev/ESPAsyncWebServer.git
synced 2025-09-27 14:50:56 +02:00
Compare task handles instead of opaque undocumented symbols
Based on commit 9b98550f64000b937db9567b69e1275feccf1f0f 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.
This commit is contained in:
@@ -44,7 +44,7 @@ class AsyncWebLock
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
SemaphoreHandle_t _lock;
|
SemaphoreHandle_t _lock;
|
||||||
mutable void *_lockedBy;
|
mutable TaskHandle_t _lockedBy{};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AsyncWebLock() {
|
AsyncWebLock() {
|
||||||
@@ -61,10 +61,10 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool lock() const {
|
bool lock() const {
|
||||||
extern void *pxCurrentTCB;
|
const auto currentTask = xTaskGetCurrentTaskHandle();
|
||||||
if (_lockedBy != pxCurrentTCB) {
|
if (_lockedBy != currentTask) {
|
||||||
xSemaphoreTake(_lock, portMAX_DELAY);
|
xSemaphoreTake(_lock, portMAX_DELAY);
|
||||||
_lockedBy = pxCurrentTCB;
|
_lockedBy = currentTask;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
Reference in New Issue
Block a user