Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern When closing a tty, limit the amount of time spent ...
details: https://anonhg.NetBSD.org/src/rev/d71ac3e2c964
branches: trunk
changeset: 810132:d71ac3e2c964
user: gson <gson%NetBSD.org@localhost>
date: Wed Aug 19 12:02:55 2015 +0000
description:
When closing a tty, limit the amount of time spent waiting for the
output to drain to five seconds so that exiting processes with
buffered output for a serial port blocked by flow control or a pty
that is not being read do not hang indefinitely. Should fix PRs
kern/12534 and kern/17171. This is an updated version of the change
of tty.c 1.263.
diffstat:
sys/kern/tty.c | 28 ++++++++++++++++++++--------
1 files changed, 20 insertions(+), 8 deletions(-)
diffs (72 lines):
diff -r 56dd81cec113 -r d71ac3e2c964 sys/kern/tty.c
--- a/sys/kern/tty.c Wed Aug 19 09:57:41 2015 +0000
+++ b/sys/kern/tty.c Wed Aug 19 12:02:55 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tty.c,v 1.264 2015/06/14 16:19:31 gson Exp $ */
+/* $NetBSD: tty.c,v 1.265 2015/08/19 12:02:55 gson Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.264 2015/06/14 16:19:31 gson Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.265 2015/08/19 12:02:55 gson Exp $");
#include "opt_compat_netbsd.h"
@@ -1536,10 +1536,10 @@
}
/*
- * Wait for output to drain.
+ * Wait for output to drain, or if this times out, flush it.
*/
-int
-ttywait(struct tty *tp)
+static int
+ttywait_timo(struct tty *tp, int timo)
{
int error;
@@ -1549,9 +1549,11 @@
while ((tp->t_outq.c_cc || ISSET(tp->t_state, TS_BUSY)) &&
CONNECTED(tp) && tp->t_oproc) {
(*tp->t_oproc)(tp);
- error = ttysleep(tp, &tp->t_outcv, true, 0);
- if (error)
+ error = ttysleep(tp, &tp->t_outcv, true, timo);
+ if (error == EWOULDBLOCK) {
+ ttyflush(tp, FWRITE);
break;
+ }
}
mutex_spin_exit(&tty_lock);
@@ -1559,6 +1561,15 @@
}
/*
+ * Wait for output to drain.
+ */
+int
+ttywait(struct tty *tp)
+{
+ return ttywait_timo(tp, 0);
+}
+
+/*
* Flush if successfully wait.
*/
int
@@ -1566,7 +1577,8 @@
{
int error;
- if ((error = ttywait(tp)) == 0) {
+ error = ttywait_timo(tp, 5 * hz);
+ if (error == 0 || error == EWOULDBLOCK) {
mutex_spin_enter(&tty_lock);
ttyflush(tp, FREAD);
mutex_spin_exit(&tty_lock);
Home |
Main Index |
Thread Index |
Old Index