aboutsummaryrefslogtreecommitdiff
path: root/linuxthreads/manager.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-06-29 12:44:22 +0000
committerUlrich Drepper <drepper@redhat.com>1998-06-29 12:44:22 +0000
commitfdacb17d4819c7112a147195c5ce3c82147f4b46 (patch)
treed1c400488d3bc8dfe707645a0fc38916e223614c /linuxthreads/manager.c
parentba488034eabd1affd6b4b3e8838abde0f4d0504e (diff)
downloadglibc-fdacb17d4819c7112a147195c5ce3c82147f4b46.tar
glibc-fdacb17d4819c7112a147195c5ce3c82147f4b46.tar.gz
glibc-fdacb17d4819c7112a147195c5ce3c82147f4b46.tar.bz2
glibc-fdacb17d4819c7112a147195c5ce3c82147f4b46.zip
Update.
1998-06-29 12:27 Ulrich Drepper <drepper@cygnus.com> * argp/argp.h: Use __PMT instead of __P for function pointer. * iconv/gconv.h: Likewise. * io/fts.h: Likewise. * io/ftw.h: Likewise. * libio/libio.h: Likewise. * malloc/mcheck.h: Likewise. * misc/search.h: Likewise. * posix/glob.h: Likewise. * resolv/resolv.h: Likewise. * signal/signal.h: Likewise. * stdlib/stdlib.h: Likewise. * sysdeps/unix/sysv/linux/bits/sigaction.h: Likewise. * sysdeps/unix/sysv/linux/bits/siginfo.h: Likewise. 1998-06-26 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * Makeconfig (CPPFLAGS): Use $($(subdir)-CPPFLAGS) only once. 1998-06-27 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * posix/wordexp.c (parse_param): Fix memory leak. 1998-06-27 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * libc.map: Export _IO_ftrylockfile. 1998-06-27 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sysdeps/unix/sysv/linux/aio_sigqueue.c: Use get[pu]id instead of __get[pu]id. 1998-06-28 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * elf/dl-misc.c (_dl_debug_message): Don't cache the pid. * elf/dl-runtime.c (_dl_object_relocation_scope): Avoid adding the same search list twice. 1998-06-29 Andreas Jaeger <aj@arthur.rhein-neckar.de> * login/programs/utmpd.c (handle_requests): Set and use maximal fd used to optimize loop/select. 1998-06-24 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sysdeps/generic/init-first.c: Don't define __libc_pid. * sysdeps/unix/sysv/linux/init-first.c: Likewise. * sysdeps/mach/hurd/i386/init-first.c: Likewise. * sysdeps/mach/hurd/mips/init-first.c: Likewise. * sysdeps/arm/init-first.c: Likewise. * posix/getopt_init.c: Don't use __libc_pid. * sysdeps/unix/sysv/linux/aio_sigqueue.c: Likewise. * sysdeps/unix/sysv/linux/sigqueue.c: Likewise. * libc.map: Remove __libc_uid and __libc_pid.
Diffstat (limited to 'linuxthreads/manager.c')
-rw-r--r--linuxthreads/manager.c61
1 files changed, 13 insertions, 48 deletions
diff --git a/linuxthreads/manager.c b/linuxthreads/manager.c
index 39c103cdc4..e69abac009 100644
--- a/linuxthreads/manager.c
+++ b/linuxthreads/manager.c
@@ -37,12 +37,6 @@
struct pthread_handle_struct __pthread_handles[PTHREAD_THREADS_MAX] =
{ { LOCK_INITIALIZER, &__pthread_initial_thread, 0}, /* All NULLs */ };
-/* This is a list of terminated, but not detached threads. This can happen
- when pthread_join() is called and the pthread_reap_children() function
- removes the thread from the live list before processing the FREE_REQ
- request. */
-static pthread_descr non_detached;
-
/* Indicate whether at least one thread has a user-defined stack (if 1),
or if all threads have stacks supplied by LinuxThreads (if 0). */
int __pthread_nonstandard_stacks = 0;
@@ -83,7 +77,7 @@ static pthread_t pthread_threads_counter = 0;
static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
void * (*start_routine)(void *), void *arg,
sigset_t *mask, int father_pid);
-static void pthread_handle_free(pthread_descr th);
+static void pthread_handle_free(pthread_t th_id);
static void pthread_handle_exit(pthread_descr issuing_thread, int exitcode);
static void pthread_reap_children(void);
static void pthread_kill_all_threads(int sig, int main_thread_also);
@@ -149,7 +143,7 @@ int __pthread_manager(void *arg)
restart(request.req_thread);
break;
case REQ_FREE:
- pthread_handle_free(request.req_args.free.thread);
+ pthread_handle_free(request.req_args.free.thread_id);
break;
case REQ_PROCESS_EXIT:
pthread_handle_exit(request.req_thread,
@@ -406,14 +400,6 @@ static void pthread_exited(pid_t pid)
__pthread_unlock(th->p_lock);
if (detached)
pthread_free(th);
- else {
- /* Enqueue in the detached list. */
- th->p_nextlive = non_detached;
- if (non_detached != NULL)
- non_detached->p_prevlive = th;
- th->p_prevlive = NULL;
- non_detached = th;
- }
break;
}
}
@@ -445,49 +431,28 @@ static void pthread_reap_children(void)
/* Try to free the resources of a thread when requested by pthread_join
or pthread_detach on a terminated thread. */
-static void pthread_handle_free(pthread_descr th)
+static void pthread_handle_free(pthread_t th_id)
{
- pthread_descr t;
- /* Check that the thread th is still there -- pthread_reap_children
- might have deallocated it already */
- t = __pthread_main_thread;
- do {
- if (t == th) break;
- t = t->p_nextlive;
- } while (t != __pthread_main_thread);
- if (t != th) {
- /* Hum, it might be that the thread already was dequeued but
- wasn't detached. In the case the thread is already detached
- and we cannot find it this is a user bug but we must be
- gracious. */
- t = non_detached;
- while (t != NULL) {
- if (t == th) break;
- t = t->p_nextlive;
- }
- if (t == th) {
- if (th->p_prevlive == NULL)
- non_detached = th->p_nextlive;
- else
- th->p_prevlive->p_nextlive = th->p_nextlive;
- if (th->p_nextlive != NULL)
- th->p_nextlive->p_prevlive = th->p_prevlive;
+ pthread_handle handle = thread_handle(th_id);
+ pthread_descr th;
- /* Finally free it. */
- pthread_free (th);
- }
+ __pthread_lock(&handle->h_lock);
+ if (invalid_handle(handle, th_id)) {
+ /* pthread_reap_children has deallocated the thread already,
+ nothing needs to be done */
+ __pthread_unlock(&handle->h_lock);
return;
}
- __pthread_lock(th->p_lock);
+ th = handle->h_descr;
if (th->p_exited) {
- __pthread_unlock(th->p_lock);
+ __pthread_unlock(&handle->h_lock);
pthread_free(th);
} else {
/* The Unix process of the thread is still running.
Mark the thread as detached so that the thread manager will
deallocate its resources when the Unix process exits. */
th->p_detached = 1;
- __pthread_unlock(th->p_lock);
+ __pthread_unlock(&handle->h_lock);
}
}