From 96623db8d2fe02a66ac9176354634d41aca8c07d Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Wed, 16 Oct 2013 01:50:52 +0200 Subject: Delay TLS deallocation outside thread termination Since libc functions used up to actual thread termination (including the termination RPC itself) are to use TLS. * pthread/pt-alloc.c (initialize_pthread): Set `tcb` field of `new` to NULL. (__pthread_alloc): Deallocate TLS of to-be-reused `new` thread. * pthread/pt-create.c (__pthread_create_internal): Reset `tcb` field to NULL after deallocation. * pthread/pt-exit.c (__pthread_exit): Do not deallocate TLS. --- pthread/pt-alloc.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'pthread/pt-alloc.c') 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; -- cgit v1.2.3