diff options
-rw-r--r-- | pthread/pt-alloc.c | 13 | ||||
-rw-r--r-- | pthread/pt-create.c | 1 | ||||
-rw-r--r-- | pthread/pt-exit.c | 7 |
3 files changed, 15 insertions, 6 deletions
diff --git a/pthread/pt-alloc.c b/pthread/pt-alloc.c index 89fca8a..604d376 100644 --- a/pthread/pt-alloc.c +++ b/pthread/pt-alloc.c @@ -75,6 +75,10 @@ initialize_pthread (struct __pthread *new, int recycling) new->cancelation_handlers = 0; +#ifdef ENABLE_TLS + new->tcb = NULL; +#endif + new->next = 0; new->prevp = 0; @@ -119,6 +123,15 @@ __pthread_alloc (struct __pthread **pthread) cases, we are interrupt it. */ __pthread_thread_halt (new); +#ifdef ENABLE_TLS + if (new->tcb) + { + /* Drop old values */ + _dl_deallocate_tls (new->tcb, 1); + new->tcb = NULL; + } +#endif /* ENABLE_TLS */ + err = initialize_pthread (new, 1); if (! err) *pthread = new; diff --git a/pthread/pt-create.c b/pthread/pt-create.c index a88c498..a593ad0 100644 --- a/pthread/pt-create.c +++ b/pthread/pt-create.c @@ -216,6 +216,7 @@ __pthread_create_internal (struct __pthread **thread, failed_setup: #ifdef ENABLE_TLS _dl_deallocate_tls (pthread->tcb, 1); + pthread->tcb = NULL; failed_thread_tls_alloc: #endif /* ENABLE_TLS */ __pthread_thread_dealloc (pthread); diff --git a/pthread/pt-exit.c b/pthread/pt-exit.c index c47b604..8468b80 100644 --- a/pthread/pt-exit.c +++ b/pthread/pt-exit.c @@ -69,11 +69,6 @@ __pthread_exit (void *status) if (self->cancel_state == PTHREAD_CANCEL_ENABLE && self->cancel_pending) status = PTHREAD_CANCELED; -#ifdef ENABLE_TLS - if (self->tcb) - _dl_deallocate_tls (self->tcb, 1); -#endif /* ENABLE_TLS */ - switch (self->state) { default: @@ -85,7 +80,7 @@ __pthread_exit (void *status) /* Make sure that nobody can reference this thread anymore, and mark it as terminated. Our thread ID will immediately become available for re-use. For obvious reasons, we cannot - deallocate our own stack. However, it will eventually be + deallocate our own stack and TLS. However, it will eventually be reused when this thread structure is recycled. */ __pthread_mutex_unlock (&self->state_lock); |