diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2010-07-02 17:27:02 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2010-07-02 17:27:02 +0000 |
commit | 3e0af5ec85e0fe2f9cb51541466d2567ea534a8f (patch) | |
tree | 98ea4006ae16bfe6a1b3730074d23b083948b395 /sys/kern | |
parent | 4d2486b3dbf3e9ae0c6d38b616a80feed0b5e05a (diff) |
Move common code for waking up writers on a tty into a function.
ok deraadt matthew millert
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/tty.c | 18 | ||||
-rw-r--r-- | sys/kern/tty_pty.c | 10 |
2 files changed, 19 insertions, 9 deletions
diff --git a/sys/kern/tty.c b/sys/kern/tty.c index b83cec50834..d946e0d11cd 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.c,v 1.86 2010/06/28 14:13:35 deraadt Exp $ */ +/* $OpenBSD: tty.c,v 1.87 2010/07/02 17:27:01 nicm Exp $ */ /* $NetBSD: tty.c,v 1.68.4.2 1996/06/06 16:04:52 thorpej Exp $ */ /*- @@ -2010,6 +2010,22 @@ ttyecho(int c, struct tty *tp) } /* + * Wakeup any writers if necessary. + */ +void +ttwakeupwr(struct tty *tp) +{ + + if (tp->t_outq.c_cc <= tp->t_lowat) { + if (ISSET(tp->t_state, TS_ASLEEP)) { + CLR(tp->t_state, TS_ASLEEP); + wakeup(&tp->t_outq); + } + selwakeup(&tp->t_wsel); + } +} + +/* * Wake up any readers on a tty. */ void diff --git a/sys/kern/tty_pty.c b/sys/kern/tty_pty.c index 16e63e2a12e..9e4d0135cd7 100644 --- a/sys/kern/tty_pty.c +++ b/sys/kern/tty_pty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty_pty.c,v 1.46 2010/06/28 14:13:36 deraadt Exp $ */ +/* $OpenBSD: tty_pty.c,v 1.47 2010/07/02 17:27:01 nicm Exp $ */ /* $NetBSD: tty_pty.c,v 1.33.4.1 1996/06/02 09:08:11 mrg Exp $ */ /* @@ -502,13 +502,7 @@ ptcread(dev_t dev, struct uio *uio, int flag) break; error = uiomove(buf, cc, uio); } - if (tp->t_outq.c_cc <= tp->t_lowat) { - if (tp->t_state&TS_ASLEEP) { - tp->t_state &= ~TS_ASLEEP; - wakeup(&tp->t_outq); - } - selwakeup(&tp->t_wsel); - } + ttwakeupwr(tp); if (bufcc) bzero(buf, bufcc); return (error); |