diff options
author | msmith <msmith@FreeBSD.org> | 1999-06-07 20:37:29 +0000 |
---|---|---|
committer | msmith <msmith@FreeBSD.org> | 1999-06-07 20:37:29 +0000 |
commit | 1abbd13bc2610a86a1eef7c8a73b314b2041b08e (patch) | |
tree | 693532cb98890c3e67eeaf861ab298dbf9f1749f /sys | |
parent | 8723c1b046e13165e2c29ccda2356a3b6fd5222d (diff) | |
download | FreeBSD-src-1abbd13bc2610a86a1eef7c8a73b314b2041b08e.zip FreeBSD-src-1abbd13bc2610a86a1eef7c8a73b314b2041b08e.tar.gz |
From the submitter:
- this causes POSIX locking to use the thread group leader
(p->p_leader) as the locking thread for all advisory locks.
In non-kernel-threaded code p->p_leader == p, so this will have
no effect.
This results in (more) correct POSIX threaded flock-ing semantics.
It also prevents the leader from exiting before any of the children.
(so that p->p_leader will never be stale) in exit1().
We have been running this patch for over a month now in our lab
under load and at customer sites.
Submitted by: John Plevyak <jplevyak@inktomi.com>
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/kern_descrip.c | 12 | ||||
-rw-r--r-- | sys/kern/kern_exit.c | 27 |
2 files changed, 18 insertions, 21 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index cc96d70..7b6ebe0 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)kern_descrip.c 8.6 (Berkeley) 4/19/94 - * $Id: kern_descrip.c,v 1.62 1999/05/30 16:52:54 phk Exp $ + * $Id: kern_descrip.c,v 1.63 1999/05/31 11:27:30 phk Exp $ */ #include "opt_compat.h" @@ -304,16 +304,16 @@ fcntl(p, uap) if ((fp->f_flag & FREAD) == 0) return (EBADF); p->p_flag |= P_ADVLOCK; - return (VOP_ADVLOCK(vp, (caddr_t)p, F_SETLK, &fl, flg)); + return (VOP_ADVLOCK(vp, (caddr_t)p->p_leader, F_SETLK, &fl, flg)); case F_WRLCK: if ((fp->f_flag & FWRITE) == 0) return (EBADF); p->p_flag |= P_ADVLOCK; - return (VOP_ADVLOCK(vp, (caddr_t)p, F_SETLK, &fl, flg)); + return (VOP_ADVLOCK(vp, (caddr_t)p->p_leader, F_SETLK, &fl, flg)); case F_UNLCK: - return (VOP_ADVLOCK(vp, (caddr_t)p, F_UNLCK, &fl, + return (VOP_ADVLOCK(vp, (caddr_t)p->p_leader, F_UNLCK, &fl, F_POSIX)); default: @@ -334,7 +334,7 @@ fcntl(p, uap) return (EINVAL); if (fl.l_whence == SEEK_CUR) fl.l_start += fp->f_offset; - if ((error = VOP_ADVLOCK(vp,(caddr_t)p,F_GETLK,&fl,F_POSIX))) + if ((error = VOP_ADVLOCK(vp,(caddr_t)p->p_leader,F_GETLK,&fl,F_POSIX))) return (error); return (copyout((caddr_t)&fl, (caddr_t)(intptr_t)uap->arg, sizeof(fl))); @@ -1064,7 +1064,7 @@ closef(fp, p) lf.l_len = 0; lf.l_type = F_UNLCK; vp = (struct vnode *)fp->f_data; - (void) VOP_ADVLOCK(vp, (caddr_t)p, F_UNLCK, &lf, F_POSIX); + (void) VOP_ADVLOCK(vp, (caddr_t)p->p_leader, F_UNLCK, &lf, F_POSIX); } if (--fp->f_count > 0) return (0); diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index fd66be8..91a7461 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)kern_exit.c 8.7 (Berkeley) 2/12/94 - * $Id: kern_exit.c,v 1.79 1999/04/28 01:04:26 luoqi Exp $ + * $Id: kern_exit.c,v 1.80 1999/04/28 11:36:52 phk Exp $ */ #include "opt_compat.h" @@ -143,21 +143,10 @@ exit1(p, rv) kill(p, &killArgs); nq = q; q = q->p_peers; - /* - * orphan the threads so we don't mess up - * when they call exit - */ - nq->p_peers = 0; - nq->p_leader = nq; } - - /* otherwise are we a peer? */ - } else if(p->p_peers) { - q = p->p_leader; - while(q->p_peers != p) - q = q->p_peers; - q->p_peers = p->p_peers; - } + while (p->p_peers) + tsleep((caddr_t)p, PWAIT, "exit1", 0); + } #ifdef PGINPROF vmsizmon(); @@ -200,6 +189,14 @@ exit1(p, rv) */ fdfree(p); + if(p->p_leader->p_peers) { + q = p->p_leader; + while(q->p_peers != p) + q = q->p_peers; + q->p_peers = p->p_peers; + wakeup((caddr_t)p->p_leader); + } + /* * XXX Shutdown SYSV semaphores */ |