From c1a7198e7d939cab8e6cba8029ddc5a91620f36d Mon Sep 17 00:00:00 2001 From: Bascy Date: Wed, 30 Sep 2020 14:15:47 +0200 Subject: [PATCH] Don't change owner if take() doesnt succeed (#3987) --- libraries/BLE/src/FreeRTOS.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/BLE/src/FreeRTOS.cpp b/libraries/BLE/src/FreeRTOS.cpp index 2f52b99d..7539e252 100644 --- a/libraries/BLE/src/FreeRTOS.cpp +++ b/libraries/BLE/src/FreeRTOS.cpp @@ -193,8 +193,8 @@ bool FreeRTOS::Semaphore::take(std::string owner) { } else { rc = ::xSemaphoreTake(m_semaphore, portMAX_DELAY) == pdTRUE; } - m_owner = owner; if (rc) { + m_owner = owner; log_v("Semaphore taken: %s", toString().c_str()); } else { log_e("Semaphore NOT taken: %s", toString().c_str()); @@ -218,8 +218,8 @@ bool FreeRTOS::Semaphore::take(uint32_t timeoutMs, std::string owner) { } else { rc = ::xSemaphoreTake(m_semaphore, timeoutMs / portTICK_PERIOD_MS) == pdTRUE; } - m_owner = owner; if (rc) { + m_owner = owner; log_v("Semaphore taken: %s", toString().c_str()); } else { log_e("Semaphore NOT taken: %s", toString().c_str());