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/netkey | |
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/netkey')
-rw-r--r-- | sys/netkey/key.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/sys/netkey/key.c b/sys/netkey/key.c index 4236081..12b9401 100644 --- a/sys/netkey/key.c +++ b/sys/netkey/key.c @@ -7306,14 +7306,24 @@ key_getuserfqdn() struct proc *p = curproc; char *q; - if (!p || !p->p_pgrp || !p->p_pgrp->pg_session) + if (p == NULL) return NULL; - if (!(host = key_getfqdn())) + bzero(userfqdn, sizeof(userfqdn)); + if (!(host = key_getfqdn())) { + PROC_UNLOCK(p); + return NULL; + } + PROC_LOCK(p); + if (!p->p_pgrp || !p->p_pgrp->pg_session) { + PROC_UNLOCK(p); return NULL; + } /* NOTE: s_login may not be-NUL terminated. */ - bzero(userfqdn, sizeof(userfqdn)); - bcopy(p->p_pgrp->pg_session->s_login, userfqdn, MAXLOGNAME); + SESS_LOCK(p->p_session); + bcopy(p->p_session->s_login, userfqdn, MAXLOGNAME); + SESS_UNLOCK(p->p_session); + PROC_UNLOCK(p); userfqdn[MAXLOGNAME] = '\0'; /* safeguard */ q = userfqdn + strlen(userfqdn); *q++ = '@'; |