PERFORCE change 150382 for review
Ed Schouten
ed at FreeBSD.org
Wed Sep 24 11:49:41 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=150382
Change 150382 by ed at ed_dull on 2008/09/24 11:49:24
- Don't call ttydev_leave() when tty_unlock() is good enough.
- Correct error codes of read() and write() calls.
Affected files ...
.. //depot/projects/mpsafetty/sys/kern/tty.c#44 edit
Differences ...
==== //depot/projects/mpsafetty/sys/kern/tty.c#44 (text+ko) ====
@@ -133,11 +133,12 @@
}
/*
- * Because the revoke() call already calls d_close() without making sure
- * all threads are purged from the TTY, we can only destroy the buffers
- * and such when the last thread leaves the TTY. ttydev_enter() and
- * ttydev_leave() are called from within the cdev functions, to make
- * sure we can garbage collect the TTY.
+ * Though ttydev_enter() and ttydev_leave() seem to be related, they
+ * don't have to be used together. ttydev_enter() is used by the cdev
+ * operations to prevent an actual from being processed when the TTY has
+ * been abandoned. ttydev_leave() is used by ttydev_open() and
+ * ttydev_close() to determine whether per-TTY data should be
+ * deallocated.
*/
static __inline int
@@ -287,6 +288,7 @@
done: tp->t_flags &= ~TF_OPENCLOSE;
ttydev_leave(tp);
+
return (error);
}
@@ -378,22 +380,23 @@
error = ttydev_enter(tp);
if (error)
- return (0);
+ goto done;
error = tty_wait_background(tp, curthread, SIGTTIN);
- if (error)
+ if (error) {
+ tty_unlock(tp);
goto done;
+ }
error = ttydisc_read(tp, uio, ioflag);
-done: ttydev_leave(tp);
+ tty_unlock(tp);
/*
- * The read() and write() calls should not throw an error when
- * the device is ripped offline.
+ * The read() call should not throw an error when the device is
+ * being destroyed. Silently convert it to an EOF.
*/
- if (error == ENXIO)
- return (0);
-
+done: if (error == ENXIO)
+ error = 0;
return (error);
}
@@ -405,24 +408,19 @@
error = ttydev_enter(tp);
if (error)
- return (0);
+ return (error);
if (tp->t_termios.c_lflag & TOSTOP) {
error = tty_wait_background(tp, curthread, SIGTTOU);
- if (error)
- goto done;
+ if (error) {
+ tty_unlock(tp);
+ return (error);
+ }
}
error = ttydisc_write(tp, uio, ioflag);
-done: ttydev_leave(tp);
+ tty_unlock(tp);
- /*
- * The read() and write() calls should not throw an error when
- * the device is ripped offline.
- */
- if (error == ENXIO)
- return (0);
-
return (error);
}
@@ -479,7 +477,7 @@
}
error = tty_ioctl(tp, cmd, data, td);
-done: ttydev_leave(tp);
+done: tty_unlock(tp);
return (error);
}
@@ -518,7 +516,7 @@
selrecord(td, &tp->t_outpoll);
}
- ttydev_leave(tp);
+ tty_unlock(tp);
return (revents);
}
@@ -535,7 +533,7 @@
if (error)
return (-1);
error = ttydevsw_mmap(tp, offset, paddr, nprot);
- ttydev_leave(tp);
+ tty_unlock(tp);
return (error);
}
@@ -623,7 +621,7 @@
break;
}
- ttydev_leave(tp);
+ tty_unlock(tp);
return (error);
}
More information about the p4-projects
mailing list