Skip to content

Commit

Permalink
Merge branch 'contrib/github_pr_14084' into 'master'
Browse files Browse the repository at this point in the history
remove TLS pointer/deletion callback from correct thread (GitHub PR)

Closes IDFGH-13144

See merge request espressif/esp-idf!31766
  • Loading branch information
ESP-Marius committed Jul 2, 2024
2 parents 15219e2 + c1e58e7 commit 15b05d5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions components/pthread/pthread_local_storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ static void pthread_cleanup_thread_specific_data_callback(int index, void *v_tls
free(tls);
}

/* this function called from pthread_task_func for "early" cleanup of TLS in a pthread */
/* this function called from pthread_task_func for "early" cleanup of TLS in a pthread
and from pthread_join/pthread_detach for cleanup of TLS after pthread exit
*/
void pthread_internal_local_storage_destructor_callback(TaskHandle_t handle)
{
void *tls = pvTaskGetThreadLocalStoragePointer(handle, PTHREAD_TLS_INDEX);
Expand All @@ -157,9 +159,9 @@ void pthread_internal_local_storage_destructor_callback(TaskHandle_t handle)
calling it again...
*/
#if !defined(CONFIG_FREERTOS_TLSP_DELETION_CALLBACKS)
vTaskSetThreadLocalStoragePointer(NULL, PTHREAD_TLS_INDEX, NULL);
vTaskSetThreadLocalStoragePointer(handle, PTHREAD_TLS_INDEX, NULL);
#else
vTaskSetThreadLocalStoragePointerAndDelCallback(NULL,
vTaskSetThreadLocalStoragePointerAndDelCallback(handle,
PTHREAD_TLS_INDEX,
NULL,
NULL);
Expand Down

0 comments on commit 15b05d5

Please sign in to comment.