summaryrefslogtreecommitdiffstats
path: root/sys/kern/tty.c
diff options
context:
space:
mode:
authorkettenis <kettenis@openbsd.org>2008-12-24 11:20:31 +0000
committerkettenis <kettenis@openbsd.org>2008-12-24 11:20:31 +0000
commit70bab234b5f0b6e40a859d49bb05095a565790d4 (patch)
tree21c5054671a906d0270fcaa2ac16f61d843e95ff /sys/kern/tty.c
parenttypo spotted by Alexey Suslikov (diff)
downloadwireguard-openbsd-70bab234b5f0b6e40a859d49bb05095a565790d4.tar.xz
wireguard-openbsd-70bab234b5f0b6e40a859d49bb05095a565790d4.zip
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@
Diffstat (limited to 'sys/kern/tty.c')
-rw-r--r--sys/kern/tty.c10
1 files changed, 7 insertions, 3 deletions
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