From a5ee8817892d40391c82289f1851a6542bce58ae Mon Sep 17 00:00:00 2001 From: Michael Balzer Date: Mon, 21 Dec 2020 13:55:27 +0100 Subject: [PATCH] pthread: copy priority inheritance fix from espressif commit 202e6c8984255b551e29e3182e091cf7cd0153b0 --- components/pthread/pthread.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/components/pthread/pthread.c b/components/pthread/pthread.c index ef87e8f22..55d90978f 100644 --- a/components/pthread/pthread.c +++ b/components/pthread/pthread.c @@ -591,12 +591,15 @@ int pthread_mutex_destroy(pthread_mutex_t *mutex) return EBUSY; } - // FreeRTOS mutex must not be deleted while taken (breaks priority inheritance): - vTaskSuspendAll(); - pthread_mutex_unlock(mutex); + if (mux->type == PTHREAD_MUTEX_RECURSIVE) { + res = xSemaphoreGiveRecursive(mux->sem); + } else { + res = xSemaphoreGive(mux->sem); + } + if (res != pdTRUE) { + assert(false && "Failed to release mutex!"); + } vSemaphoreDelete(mux->sem); - xTaskResumeAll(); - free(mux); return 0;