aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey A. Chernov <ache@FreeBSD.org>1995-01-05 00:01:07 +0000
committerAndrey A. Chernov <ache@FreeBSD.org>1995-01-05 00:01:07 +0000
commit33c38bd57424b5403e3c312a6c1f0bcc2e6c5c2b (patch)
treed4ff4b85e6fc8d40944cd83ff263766475a7abae
parentb77430dcb01156da692f60983016a1b9a20d501c (diff)
downloadsrc-33c38bd57424b5403e3c312a6c1f0bcc2e6c5c2b.tar.gz
src-33c38bd57424b5403e3c312a6c1f0bcc2e6c5c2b.zip
Fight against hanging modems: add timeout to ttywait.
Reviewed by: Bruce
Notes
Notes: svn path=/head/; revision=5396
-rw-r--r--sys/dev/sio/sio.c5
-rw-r--r--sys/i386/isa/sio.c5
-rw-r--r--sys/isa/sio.c5
-rw-r--r--sys/kern/tty.c17
-rw-r--r--sys/sys/tty.h3
-rw-r--r--sys/sys/ttycom.h6
6 files changed, 23 insertions, 18 deletions
diff --git a/sys/dev/sio/sio.c b/sys/dev/sio/sio.c
index bb30c4290fc4..638ef70fd934 100644
--- a/sys/dev/sio/sio.c
+++ b/sys/dev/sio/sio.c
@@ -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);
diff --git a/sys/i386/isa/sio.c b/sys/i386/isa/sio.c
index bb30c4290fc4..638ef70fd934 100644
--- a/sys/i386/isa/sio.c
+++ b/sys/i386/isa/sio.c
@@ -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);
diff --git a/sys/isa/sio.c b/sys/isa/sio.c
index bb30c4290fc4..638ef70fd934 100644
--- a/sys/isa/sio.c
+++ b/sys/isa/sio.c
@@ -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);
diff --git a/sys/kern/tty.c b/sys/kern/tty.c
index 85669e81fad8..e72c9632bf2d 100644
--- a/sys/kern/tty.c
+++ b/sys/kern/tty.c
@@ -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;
}
diff --git a/sys/sys/tty.h b/sys/sys/tty.h
index 275c7f92b21f..60a2daa19ce3 100644
--- a/sys/sys/tty.h
+++ b/sys/sys/tty.h
@@ -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. */
diff --git a/sys/sys/ttycom.h b/sys/sys/ttycom.h
index 320d3ebb6ed0..676222036517 100644
--- a/sys/sys/ttycom.h
+++ b/sys/sys/ttycom.h
@@ -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 */