diff options
Diffstat (limited to 'pthread/pt-dealloc.c')
-rw-r--r-- | pthread/pt-dealloc.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/pthread/pt-dealloc.c b/pthread/pt-dealloc.c index 92fe1fd..e324800 100644 --- a/pthread/pt-dealloc.c +++ b/pthread/pt-dealloc.c @@ -23,6 +23,8 @@ #include <pt-internal.h> +#include <bits/pt-atomic.h> + /* List of thread structures corresponding to free thread IDs. */ extern struct __pthread *__pthread_free_threads; extern pthread_mutex_t __pthread_free_threads_lock; @@ -34,6 +36,9 @@ __pthread_dealloc (struct __pthread *pthread) { assert (pthread->state != PTHREAD_TERMINATED); + if (! __atomic_dec_and_test (&pthread->nr_refs)) + return; + /* Withdraw this thread from the thread ID lookup table. */ __pthread_setid (pthread->thread, NULL); |