summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDoug White <dwhite@FreeBSD.org>2005-05-06 00:34:42 +0000
committerDoug White <dwhite@FreeBSD.org>2005-05-06 00:34:42 +0000
commit17b308027d0d1df4cc0817dd342afb66d517b0d4 (patch)
tree2a7a4604e02c9edef30dfd04214796c173197a9f
parent3d66f1176114297532dfde11102c783adba95593 (diff)
downloadsrc-test2-17b308027d0d1df4cc0817dd342afb66d517b0d4.tar.gz
src-test2-17b308027d0d1df4cc0817dd342afb66d517b0d4.zip
Notes
-rw-r--r--sys/kern/tty.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/sys/kern/tty.c b/sys/kern/tty.c
index fa3fe3f9fbfa..b02b4bf5f964 100644
--- a/sys/kern/tty.c
+++ b/sys/kern/tty.c
@@ -2748,7 +2748,7 @@ ttyrel(struct tty *tp)
("ttyrel(): tty refcnt is %d (%s)",
tp->t_refcnt, tp->t_dev != NULL ? devtoname(tp->t_dev) : "??"));
i = --tp->t_refcnt;
- if (i != 0) {
+ if (i > 0) {
mtx_unlock(&tp->t_mtx);
mtx_unlock(&tty_list_mutex);
return (i);
@@ -2783,7 +2783,17 @@ ttymalloc(struct tty *tp)
* XXX: require it and do a ttyrel(tp) here and allocate
* XXX: a new tty. For now do nothing.
*/
- return(tp);
+ /*
+ * If ttyrel() will recycle the tty, go ahead
+ * and let it. Otherwise conform to the old behavior.
+ * The console device in particular ends up here with
+ * positive refcounts, and destroying it really messes
+ * up init.
+ */
+ if(tp->t_refcnt <= 1)
+ ttyrel(tp);
+ else
+ return(tp);
}
tp = malloc(sizeof *tp, M_TTYS, M_WAITOK | M_ZERO);
tp->t_timeout = -1;