diff options
author | tanimura <tanimura@FreeBSD.org> | 2002-02-23 11:12:57 +0000 |
---|---|---|
committer | tanimura <tanimura@FreeBSD.org> | 2002-02-23 11:12:57 +0000 |
commit | a09da298590e8c11ebafa37f79e0046814665237 (patch) | |
tree | 2289c653c0f7aa23498f82b603c33107952652ec /sys/fs/specfs | |
parent | 33e8ee5265ca2838260ab581a9cebdedb1e1e29b (diff) | |
download | FreeBSD-src-a09da298590e8c11ebafa37f79e0046814665237.zip FreeBSD-src-a09da298590e8c11ebafa37f79e0046814665237.tar.gz |
Lock struct pgrp, session and sigio.
New locks are:
- pgrpsess_lock which locks the whole pgrps and sessions,
- pg_mtx which protects the pgrp members, and
- s_mtx which protects the session members.
Please refer to sys/proc.h for the coverage of these locks.
Changes on the pgrp/session interface:
- pgfind() needs the pgrpsess_lock held.
- The caller of enterpgrp() is responsible to allocate a new pgrp and
session.
- Call enterthispgrp() in order to enter an existing pgrp.
- pgsignal() requires a pgrp lock held.
Reviewed by: jhb, alfred
Tested on: cvsup.jp.FreeBSD.org
(which is a quad-CPU machine running -current)
Diffstat (limited to 'sys/fs/specfs')
-rw-r--r-- | sys/fs/specfs/spec_vnops.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/sys/fs/specfs/spec_vnops.c b/sys/fs/specfs/spec_vnops.c index 9de659c..7887ddb 100644 --- a/sys/fs/specfs/spec_vnops.c +++ b/sys/fs/specfs/spec_vnops.c @@ -35,6 +35,8 @@ */ #include <sys/param.h> +#include <sys/lock.h> +#include <sys/sx.h> #include <sys/proc.h> #include <sys/systm.h> #include <sys/kernel.h> @@ -568,7 +570,7 @@ spec_close(ap) struct thread *a_td; } */ *ap; { - struct vnode *vp = ap->a_vp; + struct vnode *vp = ap->a_vp, *oldvp; struct thread *td = ap->a_td; dev_t dev = vp->v_rdev; @@ -581,11 +583,18 @@ spec_close(ap) * if the reference count is 2 (this last descriptor * plus the session), release the reference from the session. */ + oldvp = NULL; + PGRPSESS_XLOCK(); if (vcount(vp) == 2 && td && (vp->v_flag & VXLOCK) == 0 && vp == td->td_proc->p_session->s_ttyvp) { - vrele(vp); + SESS_LOCK(td->td_proc->p_session); td->td_proc->p_session->s_ttyvp = NULL; + SESS_UNLOCK(td->td_proc->p_session); + oldvp = vp; } + PGRPSESS_XUNLOCK(); + if (oldvp != NULL) + vrele(oldvp); /* * We do not want to really close the device if it * is still in use unless we are trying to close it |