In thr_exit() and kthread_exit(), only remove thread from
hash if it can directly exit, otherwise let exit1() do it. The change should be in r213950, but for unknown reason, it was lost.
This commit is contained in:
parent
d9962dc588
commit
0d036d55e7
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=214238
@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <sys/mutex.h>
|
#include <sys/mutex.h>
|
||||||
#include <sys/proc.h>
|
#include <sys/proc.h>
|
||||||
#include <sys/resourcevar.h>
|
#include <sys/resourcevar.h>
|
||||||
|
#include <sys/rwlock.h>
|
||||||
#include <sys/signalvar.h>
|
#include <sys/signalvar.h>
|
||||||
#include <sys/sx.h>
|
#include <sys/sx.h>
|
||||||
#include <sys/unistd.h>
|
#include <sys/unistd.h>
|
||||||
@ -315,17 +316,20 @@ kthread_exit(void)
|
|||||||
|
|
||||||
p = curthread->td_proc;
|
p = curthread->td_proc;
|
||||||
|
|
||||||
tidhash_remove(curthread);
|
|
||||||
|
|
||||||
/* A module may be waiting for us to exit. */
|
/* A module may be waiting for us to exit. */
|
||||||
wakeup(curthread);
|
wakeup(curthread);
|
||||||
|
rw_wlock(&tidhash_lock);
|
||||||
PROC_LOCK(p);
|
PROC_LOCK(p);
|
||||||
if (p->p_numthreads == 1) {
|
if (p->p_numthreads == 1) {
|
||||||
PROC_UNLOCK(p);
|
PROC_UNLOCK(p);
|
||||||
|
rw_wunlock(&tidhash_lock);
|
||||||
kproc_exit(0);
|
kproc_exit(0);
|
||||||
|
|
||||||
/* NOTREACHED. */
|
/* NOTREACHED. */
|
||||||
}
|
}
|
||||||
|
LIST_REMOVE(curthread, td_hash);
|
||||||
|
rw_wunlock(&tidhash_lock);
|
||||||
PROC_SLOCK(p);
|
PROC_SLOCK(p);
|
||||||
thread_exit();
|
thread_exit();
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <sys/proc.h>
|
#include <sys/proc.h>
|
||||||
#include <sys/posix4.h>
|
#include <sys/posix4.h>
|
||||||
#include <sys/resourcevar.h>
|
#include <sys/resourcevar.h>
|
||||||
|
#include <sys/rwlock.h>
|
||||||
#include <sys/sched.h>
|
#include <sys/sched.h>
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#include <sys/smp.h>
|
#include <sys/smp.h>
|
||||||
@ -284,23 +285,23 @@ thr_exit(struct thread *td, struct thr_exit_args *uap)
|
|||||||
kern_umtx_wake(td, uap->state, INT_MAX, 0);
|
kern_umtx_wake(td, uap->state, INT_MAX, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
tidhash_remove(td);
|
rw_wlock(&tidhash_lock);
|
||||||
|
|
||||||
PROC_LOCK(p);
|
PROC_LOCK(p);
|
||||||
tdsigcleanup(td);
|
|
||||||
PROC_SLOCK(p);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Shutting down last thread in the proc. This will actually
|
* Shutting down last thread in the proc. This will actually
|
||||||
* call exit() in the trampoline when it returns.
|
* call exit() in the trampoline when it returns.
|
||||||
*/
|
*/
|
||||||
if (p->p_numthreads != 1) {
|
if (p->p_numthreads != 1) {
|
||||||
|
LIST_REMOVE(td, td_hash);
|
||||||
|
rw_wunlock(&tidhash_lock);
|
||||||
|
tdsigcleanup(td);
|
||||||
|
PROC_SLOCK(p);
|
||||||
thread_stopped(p);
|
thread_stopped(p);
|
||||||
thread_exit();
|
thread_exit();
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
PROC_SUNLOCK(p);
|
|
||||||
PROC_UNLOCK(p);
|
PROC_UNLOCK(p);
|
||||||
|
rw_wunlock(&tidhash_lock);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user