Page MenuHomeFreeBSD

D58706.1794680654.diff
No OneTemporary

Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None

D58706.1794680654.diff

diff --git a/sys/kern/tty.c b/sys/kern/tty.c
--- a/sys/kern/tty.c
+++ b/sys/kern/tty.c
@@ -73,7 +73,7 @@
static MALLOC_DEFINE(M_TTY, "tty", "tty device");
-static void tty_rel_free(struct tty *tp);
+static void tty_rel_free(struct tty *tp, bool inttydevclose);
static TAILQ_HEAD(, tty) tty_list = TAILQ_HEAD_INITIALIZER(tty_list);
static struct sx tty_list_sx;
@@ -231,13 +231,15 @@
}
static void
-ttydev_leave(struct tty *tp)
+ttydev_leave(struct tty *tp, bool inttydevclose)
{
tty_assert_locked(tp);
if (tty_opened(tp) || tp->t_flags & TF_OPENCLOSE) {
/* Device is still opened somewhere. */
+ if (inttydevclose)
+ tp->t_flags &= ~TF_INDEVCLOSE;
tty_unlock(tp);
return;
}
@@ -264,7 +266,7 @@
tp->t_flags &= ~TF_OPENCLOSE;
cv_broadcast(&tp->t_dcdwait);
- tty_rel_free(tp);
+ tty_rel_free(tp, inttydevclose);
}
/*
@@ -365,7 +367,7 @@
done: tp->t_flags &= ~TF_OPENCLOSE;
cv_broadcast(&tp->t_dcdwait);
- ttydev_leave(tp);
+ ttydev_leave(tp, false);
return (error);
}
@@ -377,6 +379,11 @@
struct tty *tp = dev->si_drv1;
tty_lock(tp);
+ if ((tp->t_flags & TF_INDEVCLOSE) != 0) {
+ tty_unlock(tp);
+ return (0);
+ }
+ tp->t_flags |= TF_INDEVCLOSE;
/*
* Don't actually close the device if it is being used as the
@@ -390,6 +397,7 @@
tp->t_flags &= ~(TF_OPENED_IN|TF_OPENED_OUT);
if (tp->t_flags & TF_OPENED) {
+ tp->t_flags &= ~TF_INDEVCLOSE;
tty_unlock(tp);
return (0);
}
@@ -409,7 +417,7 @@
cv_broadcast(&tp->t_bgwait);
cv_broadcast(&tp->t_dcdwait);
- ttydev_leave(tp);
+ ttydev_leave(tp, true);
return (0);
}
@@ -1146,7 +1154,7 @@
}
static void
-tty_rel_free(struct tty *tp)
+tty_rel_free(struct tty *tp, bool inttydevclose)
{
struct cdev *dev;
@@ -1155,6 +1163,8 @@
#define TF_ACTIVITY (TF_GONE|TF_OPENED|TF_HOOK|TF_OPENCLOSE)
if (tp->t_sessioncnt != 0 || (tp->t_flags & TF_ACTIVITY) != TF_GONE) {
/* TTY is still in use. */
+ if (inttydevclose)
+ tp->t_flags &= ~TF_INDEVCLOSE;
tty_unlock(tp);
return;
}
@@ -1165,6 +1175,8 @@
/* TTY can be deallocated. */
dev = tp->t_dev;
tp->t_dev = NULL;
+ if (inttydevclose)
+ tp->t_flags &= ~TF_INDEVCLOSE;
tty_unlock(tp);
if (dev != NULL) {
@@ -1201,7 +1213,7 @@
MPASS(tp->t_pgrp == NULL);
}
tp->t_sessioncnt--;
- tty_rel_free(tp);
+ tty_rel_free(tp, false);
}
void
@@ -1220,7 +1232,7 @@
cv_broadcast(&tp->t_dcdwait);
tp->t_flags |= TF_GONE;
- tty_rel_free(tp);
+ tty_rel_free(tp, false);
}
static int
@@ -2231,7 +2243,7 @@
ttydisc_optimize(tp);
/* Maybe deallocate the TTY as well. */
- tty_rel_free(tp);
+ tty_rel_free(tp, false);
}
/*
diff --git a/sys/sys/tty.h b/sys/sys/tty.h
--- a/sys/sys/tty.h
+++ b/sys/sys/tty.h
@@ -87,6 +87,7 @@
#define TF_BUSY_IN 0x20000 /* Process busy in read() -- not supported. */
#define TF_BUSY_OUT 0x40000 /* Process busy in write(). */
#define TF_BUSY (TF_BUSY_IN|TF_BUSY_OUT)
+#define TF_INDEVCLOSE 0x80000 /* In ttydev_close() */
unsigned int t_revokecnt; /* (t) revoke() count. */
/* Buffering mechanisms. */

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 14, 6:24 PM (13 h, 42 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41730372
Default Alt Text
D58706.1794680654.diff (2 KB)

Event Timeline