Don't change owner if take() doesnt succeed (#3987)

This commit is contained in:
Bascy 2020-09-30 14:15:47 +02:00 committed by GitHub
parent 4d4a1fde36
commit c1a7198e7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -193,8 +193,8 @@ bool FreeRTOS::Semaphore::take(std::string owner) {
} else { } else {
rc = ::xSemaphoreTake(m_semaphore, portMAX_DELAY) == pdTRUE; rc = ::xSemaphoreTake(m_semaphore, portMAX_DELAY) == pdTRUE;
} }
m_owner = owner;
if (rc) { if (rc) {
m_owner = owner;
log_v("Semaphore taken: %s", toString().c_str()); log_v("Semaphore taken: %s", toString().c_str());
} else { } else {
log_e("Semaphore NOT taken: %s", toString().c_str()); log_e("Semaphore NOT taken: %s", toString().c_str());
@ -218,8 +218,8 @@ bool FreeRTOS::Semaphore::take(uint32_t timeoutMs, std::string owner) {
} else { } else {
rc = ::xSemaphoreTake(m_semaphore, timeoutMs / portTICK_PERIOD_MS) == pdTRUE; rc = ::xSemaphoreTake(m_semaphore, timeoutMs / portTICK_PERIOD_MS) == pdTRUE;
} }
m_owner = owner;
if (rc) { if (rc) {
m_owner = owner;
log_v("Semaphore taken: %s", toString().c_str()); log_v("Semaphore taken: %s", toString().c_str());
} else { } else {
log_e("Semaphore NOT taken: %s", toString().c_str()); log_e("Semaphore NOT taken: %s", toString().c_str());