Module Name:    src
Committed By:   riz
Date:           Mon Aug 20 19:15:36 UTC 2012

Modified Files:
        src/sys/kern [netbsd-6]: tty.c

Log Message:
Pull up following revision(s) (requested by christos in ticket #516):
        sys/kern/tty.c: revision 1.251
        sys/kern/tty.c: revision 1.252
        sys/kern/tty.c: revision 1.253
Better (not racy fix) from Paul Goyette.
Use the queue of the tty not garbage from the stack (Paul Goyette)
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.


To generate a diff of this commit:
cvs rdiff -u -r1.249.8.1 -r1.249.8.2 src/sys/kern/tty.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/tty.c
diff -u src/sys/kern/tty.c:1.249.8.1 src/sys/kern/tty.c:1.249.8.2
--- src/sys/kern/tty.c:1.249.8.1	Mon Mar 19 23:23:10 2012
+++ src/sys/kern/tty.c	Mon Aug 20 19:15:36 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: tty.c,v 1.249.8.1 2012/03/19 23:23:10 riz Exp $	*/
+/*	$NetBSD: tty.c,v 1.249.8.2 2012/08/20 19:15:36 riz Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.249.8.1 2012/03/19 23:23:10 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.249.8.2 2012/08/20 19:15:36 riz Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -224,7 +224,7 @@ 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;
@@ -236,6 +236,14 @@ tty_set_qsize(struct tty *tp, int newsiz
 
 	mutex_spin_enter(&tty_lock);
 
+	if (tp->t_outq.c_cc != 0) {
+		mutex_spin_exit(&tty_lock);
+		clfree(&rawq);
+		clfree(&canq);
+		clfree(&outq);
+		return EBUSY;
+	}
+
 	orawq = tp->t_rawq;
 	ocanq = tp->t_canq;
 	ooutq = tp->t_outq;
@@ -252,6 +260,8 @@ tty_set_qsize(struct tty *tp, int newsiz
 	clfree(&orawq);
 	clfree(&ocanq);
 	clfree(&ooutq);
+
+	return 0;
 }
 
 static int
@@ -1350,7 +1360,7 @@ ttioctl(struct tty *tp, u_long cmd, void
 	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. */

Reply via email to