From 5cf6803a468a7a84b98d40ffcecf4a5a67521f03 Mon Sep 17 00:00:00 2001 From: Mark Kettenis Date: Wed, 24 Dec 2008 11:20:32 +0000 Subject: EVFILT_WRITE filters should return the amount of space remaining in the write buffer, not the amount of space used. It is debatable wether the size of the write buffer is set by the size of the buffer or the high water mark. For now, go with the former since that seems to be more consistent with what the pipe and socet code does. It is also what NetBSD does. ok deraadt@ --- sys/kern/tty.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'sys') diff --git a/sys/kern/tty.c b/sys/kern/tty.c index e12779631c4..c31ce53cb65 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.c,v 1.78 2008/11/11 15:33:02 deraadt Exp $ */ +/* $OpenBSD: tty.c,v 1.79 2008/12/24 11:20:31 kettenis Exp $ */ /* $NetBSD: tty.c,v 1.68.4.2 1996/06/06 16:04:52 thorpej Exp $ */ /*- @@ -1147,9 +1147,13 @@ filt_ttywrite(struct knote *kn, long hint) { dev_t dev = (dev_t)((u_long)kn->kn_hook); struct tty *tp = (*cdevsw[major(dev)].d_tty)(dev); + int canwrite, s; - kn->kn_data = tp->t_outq.c_cc; - return (kn->kn_data <= tp->t_lowat); + s = spltty(); + kn->kn_data = tp->t_outq.c_cn - tp->t_outq.c_cc; + canwrite = (tp->t_outq.c_cc <= tp->t_lowat); + splx(s); + return (canwrite); } static int -- cgit v1.2.3