This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: pthread detach problem with glibc 2.2 on SMP
- To: Wolfram Gloger <Wolfram dot Gloger at dent dot med dot uni-muenchen dot de>
- Subject: Re: pthread detach problem with glibc 2.2 on SMP
- From: Kaz Kylheku <kaz at ashi dot footprints dot net>
- Date: Wed, 6 Dec 2000 01:10:49 -0800 (PST)
- cc: aj at suse dot de, libc-alpha at sourceware dot cygnus dot com, ro at suse dot de
On Wed, 6 Dec 2000, Wolfram Gloger wrote:
> Does the patch below help?
It probably does.
> __pthread_lock(&handle->h_lock, NULL);
> - if (invalid_handle(handle, thread_id)) {
> + th = handle->h_descr;
> + if (th == NULL || th->p_tid != thread_id) {
Note that this test you have introduced is precisely equivalent to
if (nonexisting_handle(handle, thread_id))
so it should be expressed this way. This is the same validation test that is
performed by pthread_join(). It comes to reason that pthread_detach() should
use this test also.
The invalid_handle(handle, id) test is equivalent to
nonexisting_handle(handle, id) || handle->h_descr->p_terminated
which is is clearly inappropriate here. That test is useful in something like
pthread_kill, which is only meaningful if the thread is still actually running.