From eb2f61c4df7ac117fdf58ad75905e97fff3a0cc1 Mon Sep 17 00:00:00 2001 From: christos Date: Sun, 12 Aug 2012 14:45:44 +0000 Subject: [PATCH] PR/46780: Dennis Ferguson: Take the easy way out and return EBUSY when changing the queue size if the output queue is not empty. Other solutions seemed too complex/fragile. --- sys/kern/tty.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/sys/kern/tty.c b/sys/kern/tty.c index e47c7a7a81ab..18b4233c5af0 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -1,4 +1,4 @@ -/* $NetBSD: tty.c,v 1.250 2012/03/12 18:27:08 christos Exp $ */ +/* $NetBSD: tty.c,v 1.251 2012/08/12 14:45:44 christos Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -63,7 +63,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.250 2012/03/12 18:27:08 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.251 2012/08/12 14:45:44 christos Exp $"); #include #include @@ -224,12 +224,15 @@ tty_get_qsize(int *qsize, int newsize) return 0; } -static void +static int tty_set_qsize(struct tty *tp, int newsize) { struct clist rawq, canq, outq; struct clist orawq, ocanq, ooutq; + if (outq.c_cc != 0) + return EBUSY; + clalloc(&rawq, newsize, 1); clalloc(&canq, newsize, 1); clalloc(&outq, newsize, 0); @@ -252,6 +255,8 @@ tty_set_qsize(struct tty *tp, int newsize) clfree(&orawq); clfree(&ocanq); clfree(&ooutq); + + return 0; } static int @@ -1350,7 +1355,7 @@ ttioctl(struct tty *tp, u_long cmd, void *data, int flag, struct lwp *l) case TIOCSQSIZE: if ((error = tty_get_qsize(&s, *(int *)data)) == 0 && s != tp->t_qsize) - tty_set_qsize(tp, s); + error = tty_set_qsize(tp, s); return error; default: /* We may have to load the compat module for this. */