From 222b18cd6c536fc68f1c91dfdd9bed1940c181f7 Mon Sep 17 00:00:00 2001 From: Simon Schubert Date: Mon, 12 Mar 2007 21:05:48 +0000 Subject: [PATCH] Add precautions so that threads won't race to exit1() and get stuck there. --- sys/kern/kern_exit.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index 997f012596..bc8a486b1a 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -37,7 +37,7 @@ * * @(#)kern_exit.c 8.7 (Berkeley) 2/12/94 * $FreeBSD: src/sys/kern/kern_exit.c,v 1.92.2.11 2003/01/13 22:51:16 dillon Exp $ - * $DragonFly: src/sys/kern/kern_exit.c,v 1.78 2007/02/25 23:17:12 corecode Exp $ + * $DragonFly: src/sys/kern/kern_exit.c,v 1.79 2007/03/12 21:05:48 corecode Exp $ */ #include "opt_compat.h" @@ -178,6 +178,8 @@ killlwps(struct lwp *lp) struct proc *p = lp->lwp_proc; struct lwp *tlp; + KKASSERT((lp->lwp_flag & LWP_WEXIT) == 0); + FOREACH_LWP_IN_PROC(tlp, p) { if (tlp == lp) continue; /* don't kill the current lwp */ @@ -218,9 +220,12 @@ exit1(int rv) /* * Kill all other threads if there are any. * - * XXX TGEN Need to protect against multiple lwps of the same proc - * entering this function? + * If some other thread initiated our exit, do so. */ + if (lp->lwp_flag & LWP_WEXIT) { + KKASSERT(p->p_nthreads > 1); + lwp_exit(); + } if (p->p_nthreads > 1) killlwps(lp); -- 2.11.4.GIT