summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_kthread.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/kern/kern_kthread.c')
-rw-r--r--sys/kern/kern_kthread.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/sys/kern/kern_kthread.c b/sys/kern/kern_kthread.c
index 9ab0922..be40c80 100644
--- a/sys/kern/kern_kthread.c
+++ b/sys/kern/kern_kthread.c
@@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$");
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/resourcevar.h>
+#include <sys/rwlock.h>
#include <sys/signalvar.h>
#include <sys/sx.h>
#include <sys/unistd.h>
@@ -315,17 +316,20 @@ kthread_exit(void)
p = curthread->td_proc;
- tidhash_remove(curthread);
/* A module may be waiting for us to exit. */
wakeup(curthread);
+ rw_wlock(&tidhash_lock);
PROC_LOCK(p);
if (p->p_numthreads == 1) {
PROC_UNLOCK(p);
+ rw_wunlock(&tidhash_lock);
kproc_exit(0);
/* NOTREACHED. */
}
+ LIST_REMOVE(curthread, td_hash);
+ rw_wunlock(&tidhash_lock);
PROC_SLOCK(p);
thread_exit();
}
OpenPOWER on IntegriCloud