diff options
author | Mike Makonnen <mtm@FreeBSD.org> | 2004-10-13 11:42:20 +0000 |
---|---|---|
committer | Mike Makonnen <mtm@FreeBSD.org> | 2004-10-13 11:42:20 +0000 |
commit | 5dbd7addb0c95cbb67b871228385fa90ca7a9ab4 (patch) | |
tree | 8483c07b545b86140bcdf0b51159f6be244af2bc /lib/libthr/thread/thr_exit.c | |
parent | 43b42e0a71cc2e78d2cc84ed70e7395257c42b81 (diff) |
1. Now that it's a thread's state is changed from within the kernel, where
no userland locks are heald, the dead thread lock can no longer protect
access to it. Therefore, instead of using an if (!dead)...else clause
after walking the active threads list test the thread pointer before
deciding not to walk the dead threads list. If the thread pointer is null
it means it was not found in the active threads list and the dead threads
list should be checked.
2. Do not free the stack of a thread that is not marked dead. This is the
2nd and final part of eliminating the race to free a thread's stack.
MFC after: 3 days
Notes
Notes:
svn path=/head/; revision=136483
Diffstat (limited to 'lib/libthr/thread/thr_exit.c')
-rw-r--r-- | lib/libthr/thread/thr_exit.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/libthr/thread/thr_exit.c b/lib/libthr/thread/thr_exit.c index 6a4568788f32..f74b5e187775 100644 --- a/lib/libthr/thread/thr_exit.c +++ b/lib/libthr/thread/thr_exit.c @@ -195,7 +195,8 @@ deadlist_free_threads() TAILQ_FOREACH_SAFE(ptd, &_dead_list, dle, ptdTemp) { /* Don't destroy the initial thread or non-detached threads. */ if (ptd == _thread_initial || - (ptd->attr.flags & PTHREAD_DETACHED) == 0) + (ptd->attr.flags & PTHREAD_DETACHED) == 0 || + !ptd->isdead) continue; TAILQ_REMOVE(&_dead_list, ptd, dle); deadlist_free_onethread(ptd); |