Fight against hanging modems: add timeout to ttywait.
Reviewed by: Bruce
This commit is contained in:
+1
-4
@@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)com.c 7.5 (Berkeley) 5/16/91
|
||||
* $Id: sio.c,v 1.61 1994/12/01 23:48:09 ache Exp $
|
||||
* $Id: sio.c,v 1.62 1994/12/27 13:07:07 bde Exp $
|
||||
*/
|
||||
|
||||
#include "sio.h"
|
||||
@@ -901,7 +901,6 @@ sioclose(dev, flag, mode, p)
|
||||
int mynor;
|
||||
int s;
|
||||
struct tty *tp;
|
||||
void endtsleep __P((void *));
|
||||
|
||||
mynor = minor(dev);
|
||||
if (mynor & CONTROL_MASK)
|
||||
@@ -909,9 +908,7 @@ sioclose(dev, flag, mode, p)
|
||||
com = com_addr(MINOR_TO_UNIT(mynor));
|
||||
tp = com->tp;
|
||||
s = spltty();
|
||||
timeout(endtsleep, (void *)p, 60 * hz);
|
||||
(*linesw[tp->t_line].l_close)(tp, flag);
|
||||
untimeout(endtsleep, (void *)p);
|
||||
siostop(tp, FREAD | FWRITE);
|
||||
comhardclose(com);
|
||||
ttyclose(tp);
|
||||
|
||||
+1
-4
@@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)com.c 7.5 (Berkeley) 5/16/91
|
||||
* $Id: sio.c,v 1.61 1994/12/01 23:48:09 ache Exp $
|
||||
* $Id: sio.c,v 1.62 1994/12/27 13:07:07 bde Exp $
|
||||
*/
|
||||
|
||||
#include "sio.h"
|
||||
@@ -901,7 +901,6 @@ sioclose(dev, flag, mode, p)
|
||||
int mynor;
|
||||
int s;
|
||||
struct tty *tp;
|
||||
void endtsleep __P((void *));
|
||||
|
||||
mynor = minor(dev);
|
||||
if (mynor & CONTROL_MASK)
|
||||
@@ -909,9 +908,7 @@ sioclose(dev, flag, mode, p)
|
||||
com = com_addr(MINOR_TO_UNIT(mynor));
|
||||
tp = com->tp;
|
||||
s = spltty();
|
||||
timeout(endtsleep, (void *)p, 60 * hz);
|
||||
(*linesw[tp->t_line].l_close)(tp, flag);
|
||||
untimeout(endtsleep, (void *)p);
|
||||
siostop(tp, FREAD | FWRITE);
|
||||
comhardclose(com);
|
||||
ttyclose(tp);
|
||||
|
||||
+1
-4
@@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)com.c 7.5 (Berkeley) 5/16/91
|
||||
* $Id: sio.c,v 1.61 1994/12/01 23:48:09 ache Exp $
|
||||
* $Id: sio.c,v 1.62 1994/12/27 13:07:07 bde Exp $
|
||||
*/
|
||||
|
||||
#include "sio.h"
|
||||
@@ -901,7 +901,6 @@ sioclose(dev, flag, mode, p)
|
||||
int mynor;
|
||||
int s;
|
||||
struct tty *tp;
|
||||
void endtsleep __P((void *));
|
||||
|
||||
mynor = minor(dev);
|
||||
if (mynor & CONTROL_MASK)
|
||||
@@ -909,9 +908,7 @@ sioclose(dev, flag, mode, p)
|
||||
com = com_addr(MINOR_TO_UNIT(mynor));
|
||||
tp = com->tp;
|
||||
s = spltty();
|
||||
timeout(endtsleep, (void *)p, 60 * hz);
|
||||
(*linesw[tp->t_line].l_close)(tp, flag);
|
||||
untimeout(endtsleep, (void *)p);
|
||||
siostop(tp, FREAD | FWRITE);
|
||||
comhardclose(com);
|
||||
ttyclose(tp);
|
||||
|
||||
+15
-2
@@ -36,7 +36,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)tty.c 8.8 (Berkeley) 1/21/94
|
||||
* $Id: tty.c,v 1.15 1994/11/26 19:23:48 bde Exp $
|
||||
* $Id: tty.c,v 1.16 1994/12/04 01:01:45 ache Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@@ -906,6 +906,18 @@ ttioctl(tp, cmd, data, flag)
|
||||
pgsignal(tp->t_pgrp, SIGWINCH, 1);
|
||||
}
|
||||
break;
|
||||
case TIOCSDRAINWAIT:
|
||||
error = suser(p->p_ucred, &p->p_acflag);
|
||||
if (error != 0) {
|
||||
splx(s);
|
||||
return (EPERM);
|
||||
}
|
||||
tp->t_timeout = *(int *)data * hz;
|
||||
wakeup((caddr_t)&tp->t_outq);
|
||||
break;
|
||||
case TIOCGDRAINWAIT:
|
||||
*(int *)data = tp->t_timeout / hz;
|
||||
break;
|
||||
default:
|
||||
#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
|
||||
return (ttcompat(tp, cmd, data, flag));
|
||||
@@ -983,7 +995,8 @@ ttywait(tp)
|
||||
if ((tp->t_outq.c_cc || ISSET(tp->t_state, TS_BUSY)) &&
|
||||
(ISSET(tp->t_state, TS_CARR_ON) || ISSET(tp->t_cflag, CLOCAL))) {
|
||||
SET(tp->t_state, TS_ASLEEP);
|
||||
error = ttysleep(tp, &tp->t_outq, TTOPRI | PCATCH, ttyout, 0);
|
||||
error = ttysleep(tp, &tp->t_outq, TTOPRI | PCATCH,
|
||||
ttyout, tp->t_timeout);
|
||||
if (error)
|
||||
break;
|
||||
}
|
||||
|
||||
+2
-1
@@ -36,7 +36,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)tty.h 8.6 (Berkeley) 1/21/94
|
||||
* $Id: tty.h,v 1.6 1994/10/02 17:25:02 phk Exp $
|
||||
* $Id: tty.h,v 1.7 1994/11/26 19:24:13 bde Exp $
|
||||
*/
|
||||
|
||||
#ifndef _SYS_TTY_H_
|
||||
@@ -76,6 +76,7 @@ struct tty {
|
||||
dev_t t_dev; /* Device. */
|
||||
int t_state; /* Device and driver (TS*) state. */
|
||||
int t_flags; /* Tty flags. */
|
||||
int t_timeout; /* Timeout for ttywait() */
|
||||
struct pgrp *t_pgrp; /* Foreground process group. */
|
||||
struct session *t_session; /* Enclosing session. */
|
||||
struct selinfo t_rsel; /* Tty read/oob select. */
|
||||
|
||||
+3
-3
@@ -36,7 +36,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)ttycom.h 8.1 (Berkeley) 3/28/94
|
||||
* $Id: ttycom.h,v 1.5 1994/09/13 03:19:19 phk Exp $
|
||||
* $Id: ttycom.h,v 1.6 1994/11/30 15:02:43 davidg Exp $
|
||||
*/
|
||||
|
||||
#ifndef _SYS_TTYCOM_H_
|
||||
@@ -122,14 +122,14 @@ struct winsize {
|
||||
#define TIOCEXT _IOW('t', 96, int) /* pty: external processing */
|
||||
#define TIOCSIG _IO('t', 95) /* pty: generate signal */
|
||||
#define TIOCDRAIN _IO('t', 94) /* wait till output drained */
|
||||
#define TIOCMSBIDIR _IOW('t', 93, int) /* modem: set bidir cap. */
|
||||
#define TIOCMGBIDIR _IOR('t', 92, int) /* modem: get bidir cap. */
|
||||
#define TIOCMSDTRWAIT _IOW('t', 91, int) /* modem: set wait on close */
|
||||
#define TIOCMGDTRWAIT _IOR('t', 90, int) /* modem: get wait on close */
|
||||
#define TIOCTIMESTAMP _IOR('t', 89, struct timeval) /* get timestamp of
|
||||
last interrupt for xntp. */
|
||||
#define TIOCDSIMICROCODE _IO('t', 88) /* Download microcode to
|
||||
DSI Softmodem */
|
||||
#define TIOCSDRAINWAIT _IOW('t', 87, int) /* set ttywait timeout */
|
||||
#define TIOCGDRAINWAIT _IOR('t', 86, int) /* get ttywait timeout */
|
||||
|
||||
#define TTYDISC 0 /* termios tty line discipline */
|
||||
#define TABLDISC 3 /* tablet discipline */
|
||||
|
||||
Reference in New Issue
Block a user