From 50a5d4825869a40ecddf650181b6c4f75dfc6dd0 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Sun, 12 Apr 2009 00:00:00 +0200 Subject: [UNFINISHED] Fix handling of have_kernel_resources on Mach/Hurd. Further comments by Neal: do you want a reply on the libpthread one inline? the short answer is: yes, that's a bug unfortunately, your fix is not enough the predicate controls two resources: the wakeup port and the thread itself Oh, right, I see. also, there may be a race: set the predicate to free, then kill the thread that's not so good so a proper solution requires a bit more thought I think I wondered about that as well. But isn't there the same problem with Viengoos? it is difficult as cleanly committing suicide is hard :-) could be on viengoos, I don't actually deallocate the thread in pt-thread-halt.c I just call suspend the thread is only deallocated in pt-thread-dealloc.c --- sysdeps/mach/pt-thread-halt.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'sysdeps/mach/pt-thread-halt.c') diff --git a/sysdeps/mach/pt-thread-halt.c b/sysdeps/mach/pt-thread-halt.c index 973cde1..a9c3858 100644 --- a/sysdeps/mach/pt-thread-halt.c +++ b/sysdeps/mach/pt-thread-halt.c @@ -32,6 +32,21 @@ void __pthread_thread_halt (struct __pthread *thread) { - error_t err = __thread_terminate (thread->kernel_thread); - assert_perror (err); + if (thread->have_kernel_resources) + { + if (thread == _pthread_self ()) + { + while (1) + { + error_t err = __thread_suspend (thread->kernel_thread); + assert_perror (err); + assert (! "Failed to suspend self."); + } + } + else + { + error_t err = __thread_terminate (thread->kernel_thread); + assert_perror (err); + } + } } -- cgit v1.2.3