From 505347b0b29cfe3877a2deba4dedbd636990e3de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Sun, 20 Aug 2006 21:34:25 +0000 Subject: [PATCH] Threads are now removed from the hashtable earlier, so that a kill() following a waitpid() can no longer succeed; this fixes the occasional fork 3-1 test failures. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18544 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/thread.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/system/kernel/thread.c b/src/system/kernel/thread.c index e35ad2971d..e49b247456 100644 --- a/src/system/kernel/thread.c +++ b/src/system/kernel/thread.c @@ -850,17 +850,11 @@ thread_exit2(void *_args) TRACE(("thread_exit2: removing thread 0x%lx from global lists\n", args.thread->id)); disable_interrupts(); - GRAB_TEAM_LOCK(); + remove_thread_from_team(team_get_kernel_team(), args.thread); + RELEASE_TEAM_LOCK(); - - // TODO: this needs to be done earlier, so that this thread cannot be found on its last trip - GRAB_THREAD_LOCK(); - hash_remove(sThreadHash, args.thread); - sUsedThreads--; - RELEASE_THREAD_LOCK(); - enable_interrupts(); // needed for the debugger notification below @@ -921,12 +915,15 @@ thread_exit(void) // boost our priority to get this over with thread->priority = thread->next_priority = B_URGENT_DISPLAY_PRIORITY; - // stop debugging for this thread + // Stop debugging for this thread, and remove it from the hashtable, so it + // cannot be found afterwards anymore state = disable_interrupts(); GRAB_THREAD_LOCK(); debugInfo = thread->debug_info; clear_thread_debug_info(&thread->debug_info, true); + hash_remove(sThreadHash, thread); + sUsedThreads--; RELEASE_THREAD_LOCK(); restore_interrupts(state);