From ee5d48553adde607b88bcbb1ac533d88f6a0207a Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sat, 10 Jun 2000 07:45:56 +0000 Subject: [PATCH] Update. 2000-06-10 Ulrich Drepper * pthread.c (__pthread_create_2_1): Optimize a bit. * internals.h (invalid_handle): Also test for p_terminated != 0. (nonexisting_handle): New function. Same as old invalid_handle. * join.c (pthread_join): Use nonexisting_handle instead of invalid_handle to test for acceptable thread handle. Reported by Permaine Cheung . --- linuxthreads/ChangeLog | 10 ++++++++++ linuxthreads/internals.h | 5 +++++ linuxthreads/join.c | 2 +- linuxthreads/pthread.c | 6 ++++-- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/linuxthreads/ChangeLog b/linuxthreads/ChangeLog index aa3a6f0..57e653c 100644 --- a/linuxthreads/ChangeLog +++ b/linuxthreads/ChangeLog @@ -1,3 +1,13 @@ +2000-06-10 Ulrich Drepper + + * pthread.c (__pthread_create_2_1): Optimize a bit. + + * internals.h (invalid_handle): Also test for p_terminated != 0. + (nonexisting_handle): New function. Same as old invalid_handle. + * join.c (pthread_join): Use nonexisting_handle instead of + invalid_handle to test for acceptable thread handle. + Reported by Permaine Cheung . + 2000-06-08 Ulrich Drepper * sysdeps/pthread/timer_routines.c (__timer_thread_queue_timer): diff --git a/linuxthreads/internals.h b/linuxthreads/internals.h index c523d6f..405af3c 100644 --- a/linuxthreads/internals.h +++ b/linuxthreads/internals.h @@ -298,6 +298,11 @@ static inline pthread_handle thread_handle(pthread_t id) static inline int invalid_handle(pthread_handle h, pthread_t id) { + return h->h_descr == NULL || h->h_descr->p_tid != id || h->h_descr->p_terminated; +} + +static inline int nonexisting_handle(pthread_handle h, pthread_t id) +{ return h->h_descr == NULL || h->h_descr->p_tid != id; } diff --git a/linuxthreads/join.c b/linuxthreads/join.c index 95c0ab6..adcac46 100644 --- a/linuxthreads/join.c +++ b/linuxthreads/join.c @@ -116,7 +116,7 @@ int pthread_join(pthread_t thread_id, void ** thread_return) extr.pu_extricate_func = join_extricate_func; __pthread_lock(&handle->h_lock, self); - if (invalid_handle(handle, thread_id)) { + if (nonexisting_handle(handle, thread_id)) { __pthread_unlock(&handle->h_lock); return ESRCH; } diff --git a/linuxthreads/pthread.c b/linuxthreads/pthread.c index 0f63127..38bf197 100644 --- a/linuxthreads/pthread.c +++ b/linuxthreads/pthread.c @@ -500,6 +500,7 @@ int __pthread_create_2_1(pthread_t *thread, const pthread_attr_t *attr, { pthread_descr self = thread_self(); struct pthread_request request; + int retval; if (__pthread_manager_request < 0) { if (__pthread_initialize_manager() < 0) return EAGAIN; } @@ -512,9 +513,10 @@ int __pthread_create_2_1(pthread_t *thread, const pthread_attr_t *attr, &request.req_args.create.mask); __libc_write(__pthread_manager_request, (char *) &request, sizeof(request)); suspend(self); - if (THREAD_GETMEM(self, p_retcode) == 0) + retval = THREAD_GETMEM(self, p_retcode; + if (retval == 0) *thread = (pthread_t) THREAD_GETMEM(self, p_retval); - return THREAD_GETMEM(self, p_retcode); + return retval; } versioned_symbol (libpthread, __pthread_create_2_1, pthread_create, GLIBC_2_1); -- 2.7.4