NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: kern/12534 (Processes can hang at exit-time on ttyout)
The following reply was made to PR kern/12534; it has been noted by GNATS.
From: Andreas Gustafsson <gson%gson.org@localhost>
To: gnats-bugs%NetBSD.org@localhost, Antti Kantee <pooka%iki.fi@localhost>
Cc:
Subject: Re: kern/12534 (Processes can hang at exit-time on ttyout)
Date: Fri, 12 Jun 2015 15:49:54 +0300
Hi,
My system that was suffering from symptoms similar to kern/12534
has now been running with the following patch for more than nine
months, and it seems to have fixed the problem and not caused any new
ones. OK to commit?
Index: src/sys/kern/tty.c
===================================================================
RCS file: /bracket/repo/src/sys/kern/tty.c,v
retrieving revision 1.249.8.2
diff -u -r1.249.8.2 tty.c
--- src/sys/kern/tty.c 20 Aug 2012 19:15:36 -0000 1.249.8.2
+++ src/sys/kern/tty.c 30 Aug 2014 13:51:17 -0000
@@ -1525,10 +1525,10 @@
}
/*
- * Wait for output to drain.
+ * Wait for output to drain, or if this times out, flush it.
*/
int
-ttywait(struct tty *tp)
+ttywait_timo(struct tty *tp, int timo)
{
int error;
@@ -1538,9 +1538,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) {
+ ttyflush(tp, FWRITE);
break;
+ }
}
mutex_spin_exit(&tty_lock);
@@ -1548,6 +1550,15 @@
}
/*
+ * Wait for output to drain.
+ */
+int
+ttywait(struct tty *tp)
+{
+ return ttywait_timo(tp, 0);
+}
+
+/*
* Flush if successfully wait.
*/
int
@@ -1555,7 +1566,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);
Index: src/sys/sys/tty.h
===================================================================
RCS file: /bracket/repo/src/sys/sys/tty.h,v
retrieving revision 1.90
diff -u -r1.90 tty.h
--- src/sys/sys/tty.h 24 Sep 2011 00:05:38 -0000 1.90
+++ src/sys/sys/tty.h 30 Aug 2014 13:51:17 -0000
@@ -286,6 +286,7 @@
int ttysleep(struct tty *, kcondvar_t *, bool, int);
int ttypause(struct tty *, int);
int ttywait(struct tty *);
+int ttywait_timo(struct tty *, int timo);
int ttywflush(struct tty *);
void ttysig(struct tty *, enum ttysigtype, int);
void tty_attach(struct tty *);
--
Andreas Gustafsson, gson%gson.org@localhost
Home |
Main Index |
Thread Index |
Old Index