Module Name:    src
Committed By:   yamt
Date:           Tue Jul 26 13:14:18 UTC 2011

Modified Files:
        src/sys/kern: tty.c tty_pty.c
        src/sys/sys: tty.h

Log Message:
stop using lbolt in tty


To generate a diff of this commit:
cvs rdiff -u -r1.245 -r1.246 src/sys/kern/tty.c
cvs rdiff -u -r1.128 -r1.129 src/sys/kern/tty_pty.c
cvs rdiff -u -r1.87 -r1.88 src/sys/sys/tty.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/tty.c
diff -u src/sys/kern/tty.c:1.245 src/sys/kern/tty.c:1.246
--- src/sys/kern/tty.c:1.245	Sun Jul 17 20:54:52 2011
+++ src/sys/kern/tty.c	Tue Jul 26 13:14:18 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: tty.c,v 1.245 2011/07/17 20:54:52 joerg Exp $	*/
+/*	$NetBSD: tty.c,v 1.246 2011/07/26 13:14:18 yamt Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.245 2011/07/17 20:54:52 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.246 2011/07/26 13:14:18 yamt Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -875,7 +875,7 @@
 			mutex_exit(proc_lock);
 			
 			mutex_spin_enter(&tty_lock);
-			error = ttysleep(tp, &lbolt, true, 0);
+			error = ttypause(tp, hz);
 			if (error) {
 				mutex_spin_exit(&tty_lock);
 				return (error);
@@ -1719,7 +1719,7 @@
 		mutex_exit(proc_lock);
 
 		mutex_spin_enter(&tty_lock);
-		error = ttysleep(tp, &lbolt, true, 0);
+		error = ttypause(tp, hz);
 		mutex_spin_exit(&tty_lock);
 		if (error)
 			return (error);
@@ -1843,7 +1843,7 @@
 			mutex_spin_enter(&tty_lock);
 			ttysig(tp, TTYSIG_PG1, SIGTSTP);
 			if (first) {
-				error = ttysleep(tp, &lbolt, true, 0);
+				error = ttypause(tp, hz);
 				mutex_spin_exit(&tty_lock);
 				if (error)
 					break;
@@ -1990,7 +1990,7 @@
 		mutex_exit(proc_lock);
 
 		mutex_spin_enter(&tty_lock);
-		error = ttysleep(tp, &lbolt, true, 0);
+		error = ttypause(tp, hz);
 		mutex_spin_exit(&tty_lock);
 		if (error)
 			goto out;
@@ -2605,7 +2605,8 @@
 
 /*
  * Sleep on chan, returning ERESTART if tty changed while we napped and
- * returning any errors (e.g. EINTR/ETIMEDOUT) reported by cv_timedwait(_sig).
+ * returning any errors (e.g. EINTR/EWOULDBLOCK) reported by
+ * cv_timedwait(_sig).
  * If the tty is revoked, restarting a pending call will redo validation done
  * at the start of the call.
  *
@@ -2620,7 +2621,9 @@
 	KASSERT(mutex_owned(&tty_lock));
 
 	gen = tp->t_gen;
-	if (catch)
+	if (cv == NULL)
+		error = kpause("ttypause", catch, timo, &tty_lock);
+	else if (catch)
 		error = cv_timedwait_sig(cv, &tty_lock, timo);
 	else
 		error = cv_timedwait(cv, &tty_lock, timo);
@@ -2629,6 +2632,17 @@
 	return (tp->t_gen == gen ? 0 : ERESTART);
 }
 
+int
+ttypause(struct tty *tp, int timo)
+{
+	int error;
+
+	error = ttysleep(tp, NULL, true, timo);
+	if (error == EWOULDBLOCK)
+		error = 0;
+	return error;
+}
+
 /*
  * Attach a tty to the tty list.
  *

Index: src/sys/kern/tty_pty.c
diff -u src/sys/kern/tty_pty.c:1.128 src/sys/kern/tty_pty.c:1.129
--- src/sys/kern/tty_pty.c:1.128	Sun Apr 24 16:26:51 2011
+++ src/sys/kern/tty_pty.c	Tue Jul 26 13:14:18 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: tty_pty.c,v 1.128 2011/04/24 16:26:51 rmind Exp $	*/
+/*	$NetBSD: tty_pty.c,v 1.129 2011/07/26 13:14:18 yamt Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tty_pty.c,v 1.128 2011/04/24 16:26:51 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tty_pty.c,v 1.129 2011/07/26 13:14:18 yamt Exp $");
 
 #include "opt_ptm.h"
 
@@ -402,7 +402,7 @@
 				return EIO;
 			}
 			ttysig(tp, TTYSIG_PG1, SIGTTIN);
-			error = ttysleep(tp, &lbolt, true, 0);
+			error = ttypause(tp, hz);
 			if (error != 0) {
 				mutex_spin_exit(&tty_lock);
 				return error;

Index: src/sys/sys/tty.h
diff -u src/sys/sys/tty.h:1.87 src/sys/sys/tty.h:1.88
--- src/sys/sys/tty.h:1.87	Sun Apr 24 16:26:52 2011
+++ src/sys/sys/tty.h	Tue Jul 26 13:14:17 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: tty.h,v 1.87 2011/04/24 16:26:52 rmind Exp $	*/
+/*	$NetBSD: tty.h,v 1.88 2011/07/26 13:14:17 yamt Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -282,6 +282,7 @@
 void	 ttyretype(struct tty *);
 void	 ttyrub(int, struct tty *);
 int	 ttysleep(struct tty *, kcondvar_t *, bool, int);
+int	 ttypause(struct tty *, int);
 int	 ttywait(struct tty *);
 int	 ttywflush(struct tty *);
 void	 ttysig(struct tty *, enum ttysigtype, int);

Reply via email to