diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2022-01-22 00:12:05 +0000 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2022-01-22 02:17:19 +0100 |
commit | 8c86ba446367fd676457e51eb44d7af2e5d9a392 (patch) | |
tree | 110b0549f3a5708a1b27714d752fa1551e465f70 /htl/pt-alloc.c | |
parent | e22a4557eb39d7cba9a74d70f4582c13f1a7a83a (diff) | |
download | glibc-8c86ba446367fd676457e51eb44d7af2e5d9a392.tar glibc-8c86ba446367fd676457e51eb44d7af2e5d9a392.tar.gz glibc-8c86ba446367fd676457e51eb44d7af2e5d9a392.tar.bz2 glibc-8c86ba446367fd676457e51eb44d7af2e5d9a392.zip |
htl: Fix cleaning the reply port
If any RPC fails, the reply port will already be deallocated.
__pthread_thread_terminate thus has to defer taking its name until the very last
__thread_terminate_release which doesn't reply a message. But then we
have to read from the pthread structure.
This introduces __pthread_dealloc_finish() which does the recording of
the thread termination, so the slot can be reused really only just before
the __thread_terminate_release call. Only the real thread can set it, so
let's decouple this from the pthread_state by just removing the
PTHREAD_TERMINATED state and add a terminated field.
Diffstat (limited to 'htl/pt-alloc.c')
-rw-r--r-- | htl/pt-alloc.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/htl/pt-alloc.c b/htl/pt-alloc.c index 4b012a0c32..f6ab201812 100644 --- a/htl/pt-alloc.c +++ b/htl/pt-alloc.c @@ -54,6 +54,7 @@ initialize_pthread (struct __pthread *new) new->state_lock = (pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER; new->state_cond = (pthread_cond_t) PTHREAD_COND_INITIALIZER; + new->terminated = FALSE; memset (&new->res_state, '\0', sizeof (new->res_state)); @@ -84,10 +85,10 @@ __pthread_alloc (struct __pthread **pthread) { /* There is no need to take NEW->STATE_LOCK: if NEW is on this list, then it is protected by __PTHREAD_FREE_THREADS_LOCK - except in __pthread_dealloc where after it is added to the + except in __pthread_dealloc_finish where after it is added to the list (with the lock held), it drops the lock and then sets NEW->STATE and immediately stops using NEW. */ - if (new->state == PTHREAD_TERMINATED) + if (new->terminated) { __pthread_dequeue (new); break; |