From: Christian Brauner Date: Thu, 13 Dec 2018 14:44:36 +0000 (+0100) Subject: terminal: remove sigwinch command X-Git-Tag: lxc-3.2.0~196^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2bd158cc0c79da7d48e36306d41b5677ec976fc6;p=thirdparty%2Flxc.git terminal: remove sigwinch command SIGWINCH is handled in lxc_terminal_signalfd_cb(). I cannot for the life of me figure out what this is supposed to do. Afaict, it scans a global list that is totally unnecessary and also let's say you have 100 ttys and for a single one SIGWINCH is sent. In that case the whole list is walked and two ioctl()s are performed: one to get window size one to set window size. For 99 of them the window size hasn't changed. If we see issues we can revert! Signed-off-by: Christian Brauner --- diff --git a/src/lxc/commands.c b/src/lxc/commands.c index 133384d72..392fdab2c 100644 --- a/src/lxc/commands.c +++ b/src/lxc/commands.c @@ -665,7 +665,7 @@ static int lxc_cmd_stop_callback(int fd, struct lxc_cmd_req *req, } /* - * lxc_cmd_terminal_winch: To process as if a SIGWINCH were received + * lxc_cmd_terminal_winch: noop * * @name : name of container to connect to * @lxcpath : the lxcpath in which the container is running @@ -674,26 +674,14 @@ static int lxc_cmd_stop_callback(int fd, struct lxc_cmd_req *req, */ int lxc_cmd_terminal_winch(const char *name, const char *lxcpath) { - int ret, stopped; - struct lxc_cmd_rr cmd = { - .req = { .cmd = LXC_CMD_TERMINAL_WINCH }, - }; - - ret = lxc_cmd(name, &cmd, &stopped, lxcpath, NULL); - if (ret < 0) - return ret; - return 0; } static int lxc_cmd_terminal_winch_callback(int fd, struct lxc_cmd_req *req, struct lxc_handler *handler) { - struct lxc_cmd_rsp rsp = { .data = 0 }; - - lxc_terminal_sigwinch(SIGWINCH); - - return lxc_cmd_rsp_send(fd, &rsp); + /* should never be called */ + return -1; } /* diff --git a/src/lxc/terminal.c b/src/lxc/terminal.c index 4060e7f9b..de0089101 100644 --- a/src/lxc/terminal.c +++ b/src/lxc/terminal.c @@ -59,15 +59,6 @@ lxc_log_define(terminal, lxc); -static struct lxc_list lxc_ttys; - -typedef void (*sighandler_t)(int); - -__attribute__((constructor)) void lxc_terminal_init_global(void) -{ - lxc_list_init(&lxc_ttys); -} - void lxc_terminal_winsz(int srcfd, int dstfd) { int ret; @@ -95,20 +86,6 @@ void lxc_terminal_winsz(int srcfd, int dstfd) static void lxc_terminal_winch(struct lxc_terminal_state *ts) { lxc_terminal_winsz(ts->stdinfd, ts->masterfd); - - if (ts->winch_proxy) - lxc_cmd_terminal_winch(ts->winch_proxy, ts->winch_proxy_lxcpath); -} - -void lxc_terminal_sigwinch(int sig) -{ - struct lxc_list *it; - struct lxc_terminal_state *ts; - - lxc_list_for_each(it, &lxc_ttys) { - ts = it->elem; - lxc_terminal_winch(ts); - } } int lxc_terminal_signalfd_cb(int fd, uint32_t events, void *cbdata, @@ -161,9 +138,6 @@ struct lxc_terminal_state *lxc_terminal_signal_init(int srcfd, int dstfd) if (!istty) { INFO("fd %d does not refer to a tty device", srcfd); } else { - /* Add tty to list to be scanned at SIGWINCH time. */ - lxc_list_add_elem(&ts->node, ts); - lxc_list_add_tail(&lxc_ttys, &ts->node); ret = sigaddset(&mask, SIGWINCH); if (ret < 0) SYSNOTICE("Failed to add SIGWINCH to signal set"); @@ -199,9 +173,6 @@ on_error: ts->sigfd = -1; } - if (istty) - lxc_list_del(&ts->node); - return ts; } @@ -214,9 +185,6 @@ void lxc_terminal_signal_fini(struct lxc_terminal_state *ts) SYSWARN("Failed to restore signal mask"); } - if (isatty(ts->stdinfd)) - lxc_list_del(&ts->node); - free(ts); } @@ -1065,14 +1033,12 @@ int lxc_console(struct lxc_container *c, int ttynum, goto close_fds; } ts->escape = escape; - ts->winch_proxy = c->name; - ts->winch_proxy_lxcpath = c->config_path; ts->stdoutfd = stdoutfd; istty = isatty(stdinfd); if (istty) { lxc_terminal_winsz(stdinfd, masterfd); - lxc_cmd_terminal_winch(ts->winch_proxy, ts->winch_proxy_lxcpath); + lxc_terminal_winsz(ts->stdinfd, ts->masterfd); } else { INFO("File descriptor %d does not refer to a terminal", stdinfd); } diff --git a/src/lxc/terminal.h b/src/lxc/terminal.h index bfd271f44..02f31f8d8 100644 --- a/src/lxc/terminal.h +++ b/src/lxc/terminal.h @@ -68,12 +68,6 @@ struct lxc_terminal_state { */ int saw_escape; - /* Name of the container to forward the SIGWINCH event to. */ - const char *winch_proxy; - - /* Path of the container to forward the SIGWINCH event to. */ - const char *winch_proxy_lxcpath; - /* File descriptor that accepts signals. If set to -1 no signal handler * could be installed. This also means that the sigset_t oldmask member * is meaningless.