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: 's avatarChristian Brauner <christian.brauner@ubuntu.com>
parent 40b2dcbc
...@@ -665,7 +665,7 @@ static int lxc_cmd_stop_callback(int fd, struct lxc_cmd_req *req, ...@@ -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 * @name : name of container to connect to
* @lxcpath : the lxcpath in which the container is running * @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, ...@@ -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 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; return 0;
} }
static int lxc_cmd_terminal_winch_callback(int fd, struct lxc_cmd_req *req, static int lxc_cmd_terminal_winch_callback(int fd, struct lxc_cmd_req *req,
struct lxc_handler *handler) struct lxc_handler *handler)
{ {
struct lxc_cmd_rsp rsp = { .data = 0 }; /* should never be called */
return -1;
lxc_terminal_sigwinch(SIGWINCH);
return lxc_cmd_rsp_send(fd, &rsp);
} }
/* /*
......
...@@ -59,15 +59,6 @@ ...@@ -59,15 +59,6 @@
lxc_log_define(terminal, lxc); 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) void lxc_terminal_winsz(int srcfd, int dstfd)
{ {
int ret; int ret;
...@@ -95,20 +86,6 @@ void lxc_terminal_winsz(int srcfd, int dstfd) ...@@ -95,20 +86,6 @@ void lxc_terminal_winsz(int srcfd, int dstfd)
static void lxc_terminal_winch(struct lxc_terminal_state *ts) static void lxc_terminal_winch(struct lxc_terminal_state *ts)
{ {
lxc_terminal_winsz(ts->stdinfd, ts->masterfd); 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, 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) ...@@ -161,9 +138,6 @@ struct lxc_terminal_state *lxc_terminal_signal_init(int srcfd, int dstfd)
if (!istty) { if (!istty) {
INFO("fd %d does not refer to a tty device", srcfd); INFO("fd %d does not refer to a tty device", srcfd);
} else { } 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); ret = sigaddset(&mask, SIGWINCH);
if (ret < 0) if (ret < 0)
SYSNOTICE("Failed to add SIGWINCH to signal set"); SYSNOTICE("Failed to add SIGWINCH to signal set");
...@@ -199,9 +173,6 @@ on_error: ...@@ -199,9 +173,6 @@ on_error:
ts->sigfd = -1; ts->sigfd = -1;
} }
if (istty)
lxc_list_del(&ts->node);
return ts; return ts;
} }
...@@ -214,9 +185,6 @@ void lxc_terminal_signal_fini(struct lxc_terminal_state *ts) ...@@ -214,9 +185,6 @@ void lxc_terminal_signal_fini(struct lxc_terminal_state *ts)
SYSWARN("Failed to restore signal mask"); SYSWARN("Failed to restore signal mask");
} }
if (isatty(ts->stdinfd))
lxc_list_del(&ts->node);
free(ts); free(ts);
} }
...@@ -1065,14 +1033,12 @@ int lxc_console(struct lxc_container *c, int ttynum, ...@@ -1065,14 +1033,12 @@ int lxc_console(struct lxc_container *c, int ttynum,
goto close_fds; goto close_fds;
} }
ts->escape = escape; ts->escape = escape;
ts->winch_proxy = c->name;
ts->winch_proxy_lxcpath = c->config_path;
ts->stdoutfd = stdoutfd; ts->stdoutfd = stdoutfd;
istty = isatty(stdinfd); istty = isatty(stdinfd);
if (istty) { if (istty) {
lxc_terminal_winsz(stdinfd, masterfd); lxc_terminal_winsz(stdinfd, masterfd);
lxc_cmd_terminal_winch(ts->winch_proxy, ts->winch_proxy_lxcpath); lxc_terminal_winsz(ts->stdinfd, ts->masterfd);
} else { } else {
INFO("File descriptor %d does not refer to a terminal", stdinfd); INFO("File descriptor %d does not refer to a terminal", stdinfd);
} }
......
...@@ -68,12 +68,6 @@ struct lxc_terminal_state { ...@@ -68,12 +68,6 @@ struct lxc_terminal_state {
*/ */
int saw_escape; 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 /* File descriptor that accepts signals. If set to -1 no signal handler
* could be installed. This also means that the sigset_t oldmask member * could be installed. This also means that the sigset_t oldmask member
* is meaningless. * is meaningless.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment