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)
On Jun 12, 12:55pm, gson%gson.org@localhost (Andreas Gustafsson) wrote:
-- Subject: Re: kern/12534 (Processes can hang at exit-time on ttyout)
| 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?
Well, no need to expose ttywait_timeo() since it is only used internally
(it should be static). Your fix changes the behavior of ttywflush() which
looks fine for now (since only if_sl.c and if_strip.c use it directly and
in that case it does not matter since they call it on close. I would add
a comment though to to ttywflush since it does not really wait anymore forever
as it used to do, and if one wants to really wait for it to complete, they
need to check for EWOULDBLOCK and put it in a loop. Nobody even checks
for the return for ttywflush() now so perhaps even adding the comment is
excessive :-)
I think you should commit it (with the static)
christos
|
| 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
|
-- End of excerpt from Andreas Gustafsson
Home |
Main Index |
Thread Index |
Old Index