]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
terminal: remove sigwinch command 2753/head
authorChristian Brauner <christian.brauner@ubuntu.com>
Thu, 13 Dec 2018 14:44:36 +0000 (15:44 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Thu, 13 Dec 2018 14:46:46 +0000 (15:46 +0100)
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 <christian.brauner@ubuntu.com>
src/lxc/commands.c
src/lxc/terminal.c
src/lxc/terminal.h

index 133384d723fe1e4bdc8fa5c1c13632b93a87c793..392fdab2cab85962c6a3aac5d598f627ccf1406c 100644 (file)
@@ -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;
 }
 
 /*
index 4060e7f9b486f1f03ae004d25c169b34212696d8..de00891018a7b5e7ab53023a262dfa03e6fdb735 100644 (file)
 
 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);
        }
index bfd271f446b9f6a04de79cb4fa5ccce35d51a580..02f31f8d8b28affa7e35568bcbd1ebf00b1d8f25 100644 (file)
@@ -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.