diff options
author | kib <kib@FreeBSD.org> | 2013-09-13 06:39:10 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2013-09-13 06:39:10 +0000 |
commit | b3080da236407f37102bde7b1e2cd292b78aa8ab (patch) | |
tree | c9e7fa71a0061ddb71c90429434128f2b81846eb /sys/kern/subr_prf.c | |
parent | acb9f7ba6185fe661cada92df79c40b500ea2147 (diff) | |
download | FreeBSD-src-b3080da236407f37102bde7b1e2cd292b78aa8ab.zip FreeBSD-src-b3080da236407f37102bde7b1e2cd292b78aa8ab.tar.gz |
Reduce the scope of the proctree_lock. If several processes cause
continuous calls to the uprintf(9), the proctree_lock could be
shared-locked for indefinite amount of time, starving exclusive
requests. Since proctree_lock is needed for fork() and exit(), this
effectively stops the machine.
While there, do the similar reduction for tprintf(9).
Reported and tested by: pho
Reviewed by: ed
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Approved by: re (glebius)
Diffstat (limited to 'sys/kern/subr_prf.c')
-rw-r--r-- | sys/kern/subr_prf.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/sys/kern/subr_prf.c b/sys/kern/subr_prf.c index 042afa3..93d8ed3 100644 --- a/sys/kern/subr_prf.c +++ b/sys/kern/subr_prf.c @@ -151,26 +151,25 @@ uprintf(const char *fmt, ...) PROC_LOCK(p); if ((p->p_flag & P_CONTROLT) == 0) { PROC_UNLOCK(p); - retval = 0; - goto out; + sx_sunlock(&proctree_lock); + return (0); } SESS_LOCK(p->p_session); pca.tty = p->p_session->s_ttyp; SESS_UNLOCK(p->p_session); PROC_UNLOCK(p); if (pca.tty == NULL) { - retval = 0; - goto out; + sx_sunlock(&proctree_lock); + return (0); } pca.flags = TOTTY; pca.p_bufr = NULL; va_start(ap, fmt); tty_lock(pca.tty); + sx_sunlock(&proctree_lock); retval = kvprintf(fmt, putchar, &pca, 10, ap); tty_unlock(pca.tty); va_end(ap); -out: - sx_sunlock(&proctree_lock); return (retval); } @@ -219,13 +218,13 @@ vtprintf(struct proc *p, int pri, const char *fmt, va_list ap) pca.p_bufr = NULL; if (pca.tty != NULL) tty_lock(pca.tty); + sx_sunlock(&proctree_lock); kvprintf(fmt, putchar, &pca, 10, ap); if (pca.tty != NULL) tty_unlock(pca.tty); if (sess != NULL) sess_release(sess); msgbuftrigger = 1; - sx_sunlock(&proctree_lock); } /* |