aboutsummaryrefslogtreecommitdiff
path: root/server-client.c
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2020-05-24 12:01:21 +0100
committerThomas Adam <thomas@xteddy.org>2020-05-24 12:01:21 +0100
commitaeefd585a090b6bf0d38888efde9e551a19dce07 (patch)
tree78bc5fe6adb466e539b691dd46b74b0e4b82f2a3 /server-client.c
parente71c5efd58b5160864ce851a4cbc93e5fde93685 (diff)
parent18aab909593440bfa4fe003a9f683c0fb2993461 (diff)
downloadrtmux-aeefd585a090b6bf0d38888efde9e551a19dce07.tar.gz
rtmux-aeefd585a090b6bf0d38888efde9e551a19dce07.tar.bz2
rtmux-aeefd585a090b6bf0d38888efde9e551a19dce07.zip
Merge branch 'obsd-master'
Diffstat (limited to 'server-client.c')
-rw-r--r--server-client.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/server-client.c b/server-client.c
index de81e5ee..2e474d77 100644
--- a/server-client.c
+++ b/server-client.c
@@ -227,7 +227,6 @@ server_client_create(int fd)
RB_INIT(&c->windows);
RB_INIT(&c->files);
- c->tty.fd = -1;
c->tty.sx = 80;
c->tty.sy = 24;
@@ -305,10 +304,8 @@ server_client_lost(struct client *c)
TAILQ_REMOVE(&clients, c, entry);
log_debug("lost client %p", c);
- /*
- * If CLIENT_TERMINAL hasn't been set, then tty_init hasn't been called
- * and tty_free might close an unrelated fd.
- */
+ if (c->flags & CLIENT_CONTROL)
+ control_stop(c);
if (c->flags & CLIENT_TERMINAL)
tty_free(&c->tty);
free(c->ttyname);
@@ -340,6 +337,10 @@ server_client_lost(struct client *c)
proc_remove_peer(c->peer);
c->peer = NULL;
+ if (c->fd != -1) {
+ close(c->fd);
+ c->fd = -1;
+ }
server_client_unref(c);
server_add_accept(0); /* may be more file descriptors now */
@@ -2006,7 +2007,7 @@ server_client_dispatch(struct imsg *imsg, void *arg)
break;
c->flags &= ~CLIENT_SUSPENDED;
- if (c->tty.fd == -1) /* exited in the meantime */
+ if (c->fd == -1) /* exited in the meantime */
break;
s = c->session;
@@ -2212,11 +2213,9 @@ server_client_dispatch_identify(struct client *c, struct imsg *imsg)
if (c->flags & CLIENT_CONTROL) {
close(c->fd);
c->fd = -1;
-
control_start(c);
- c->tty.fd = -1;
} else if (c->fd != -1) {
- if (tty_init(&c->tty, c, c->fd) != 0) {
+ if (tty_init(&c->tty, c) != 0) {
close(c->fd);
c->fd = -1;
} else {