From 451e13e2152f6150f2887728eba210ceeedab951 Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Thu, 17 Jan 2013 21:24:59 +0000 Subject: Ensure the tty hiwat is less than the size of the ring buffer (since we do not grow space like clist chains). Clamp it a bit more precisely, ensuring a bit of space for kernel ^T handling and such. It was definately wrong, and we can tune this if required later. ok kettenis --- sys/kern/tty.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'sys/kern') diff --git a/sys/kern/tty.c b/sys/kern/tty.c index 906702d0285..45f7283658c 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.c,v 1.95 2012/04/22 02:26:11 matthew Exp $ */ +/* $OpenBSD: tty.c,v 1.96 2013/01/17 21:24:58 deraadt Exp $ */ /* $NetBSD: tty.c,v 1.68.4.2 1996/06/06 16:04:52 thorpej Exp $ */ /*- @@ -2066,15 +2066,15 @@ ttspeedtab(int speed, const struct speedtab *table) void ttsetwater(struct tty *tp) { - int cps, x; + int cps, x, omost; #define CLAMP(x, h, l) ((x) > h ? h : ((x) < l) ? l : (x)) cps = tp->t_ospeed / 10; tp->t_lowat = x = CLAMP(cps / 2, TTMAXLOWAT, TTMINLOWAT); x += cps; - x = CLAMP(x, TTMAXHIWAT, TTMINHIWAT); - tp->t_hiwat = roundup(x, CBSIZE); + omost = MIN(tp->t_outq.c_cn - 200, tp->t_outq.c_cn); + tp->t_hiwat = CLAMP(x, omost, 100); #undef CLAMP } -- cgit v1.2.3