aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/tty.c
diff options
context:
space:
mode:
authorAlexander Motin <mav@FreeBSD.org>2021-09-04 02:18:51 +0000
committerAlexander Motin <mav@FreeBSD.org>2021-09-04 02:18:51 +0000
commitbd6085c6ae28fb1cc81cca325656332fbd2cebd8 (patch)
treefb4f381207ae5a0d135862035d5568739d5ab0d3 /sys/kern/tty.c
parentcd85b97e0e701bc87cc5bdb9844168a1f5c204e1 (diff)
downloadsrc-bd6085c6ae28fb1cc81cca325656332fbd2cebd8.tar.gz
src-bd6085c6ae28fb1cc81cca325656332fbd2cebd8.zip
Re-implement virtual console (constty).
Protect conscallout with tty lock instead of Giant. In addition to Giant removal it also closes race on console unset. Introduce additional lock to protect against concurrent console sets. Remove consbuf free on console unset as unsafe, making impossible to change buffer size after first allocation. Instead increase default buffer size from 8KB to 64KB and processing rate from 5Hz to 10-15Hz to make the output more smooth. MFC after: 1 month
Diffstat (limited to 'sys/kern/tty.c')
-rw-r--r--sys/kern/tty.c24
1 files changed, 5 insertions, 19 deletions
diff --git a/sys/kern/tty.c b/sys/kern/tty.c
index 8700eb8f9ef1..8dfe5e93780f 100644
--- a/sys/kern/tty.c
+++ b/sys/kern/tty.c
@@ -241,8 +241,7 @@ ttydev_leave(struct tty *tp)
tp->t_flags |= TF_OPENCLOSE;
/* Remove console TTY. */
- if (constty == tp)
- constty_clear();
+ constty_clear(tp);
/* Drain any output. */
if (!tty_gone(tp))
@@ -1920,24 +1919,11 @@ tty_generic_ioctl(struct tty *tp, u_long cmd, void *data, int fflag,
error = priv_check(td, PRIV_TTY_CONSOLE);
if (error)
return (error);
-
- /*
- * XXX: constty should really need to be locked!
- * XXX: allow disconnected constty's to be stolen!
- */
-
- if (constty == tp)
- return (0);
- if (constty != NULL)
- return (EBUSY);
-
- tty_unlock(tp);
- constty_set(tp);
- tty_lock(tp);
- } else if (constty == tp) {
- constty_clear();
+ error = constty_set(tp);
+ } else {
+ error = constty_clear(tp);
}
- return (0);
+ return (error);
case TIOCGWINSZ:
/* Obtain window size. */
*(struct winsize*)data = tp->t_winsize;