From a504262f3949b267c6f79e97f448ecf1f8fb1a45 Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 Date: Thu, 17 Jun 2021 14:37:13 +0200 Subject: [PATCH] Retry lock when failed and portMAX_DELAY --- src/lockhelper.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lockhelper.h b/src/lockhelper.h index e8178b6..8d57ea2 100644 --- a/src/lockhelper.h +++ b/src/lockhelper.h @@ -16,7 +16,12 @@ public: LockHelper(SemaphoreHandle_t xMutex, TickType_t xTicksToWait = portMAX_DELAY) : m_xMutex{xMutex}, m_locked{xSemaphoreTake(m_xMutex, xTicksToWait) == pdPASS} - {} + { + if (m_xMutex && + xTicksToWait == portMAX_DELAY && + !m_locked) + while (!lock(xTicksToWait)); + } ~LockHelper() {