mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/pthread_join_debug_log_v4.1' into 'release/v4.1'
pthread: Fix possible deadlock when using pthread_join() and Debug log level (v4.1) See merge request espressif/esp-idf!13778
This commit is contained in:
commit
9d82fc4447
@ -360,7 +360,7 @@ int pthread_join(pthread_t thread, void **retval)
|
|||||||
if (pthread->state == PTHREAD_TASK_STATE_RUN) {
|
if (pthread->state == PTHREAD_TASK_STATE_RUN) {
|
||||||
pthread->join_task = xTaskGetCurrentTaskHandle();
|
pthread->join_task = xTaskGetCurrentTaskHandle();
|
||||||
wait = true;
|
wait = true;
|
||||||
} else {
|
} else { // thread has exited and task is already suspended, or about to be suspended
|
||||||
child_task_retval = pthread->retval;
|
child_task_retval = pthread->retval;
|
||||||
pthread_delete(pthread);
|
pthread_delete(pthread);
|
||||||
}
|
}
|
||||||
@ -451,10 +451,14 @@ void pthread_exit(void *value_ptr)
|
|||||||
pthread->state = PTHREAD_TASK_STATE_EXIT;
|
pthread->state = PTHREAD_TASK_STATE_EXIT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xSemaphoreGive(s_threads_mux);
|
|
||||||
|
|
||||||
ESP_LOGD(TAG, "Task stk_wm = %d", uxTaskGetStackHighWaterMark(NULL));
|
ESP_LOGD(TAG, "Task stk_wm = %d", uxTaskGetStackHighWaterMark(NULL));
|
||||||
|
|
||||||
|
xSemaphoreGive(s_threads_mux);
|
||||||
|
// note: if this thread is joinable then after giving back s_threads_mux
|
||||||
|
// this task could be deleted at any time, so don't take another lock or
|
||||||
|
// do anything that might lock (such as printing to stdout)
|
||||||
|
|
||||||
if (detached) {
|
if (detached) {
|
||||||
vTaskDelete(NULL);
|
vTaskDelete(NULL);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user