summaryrefslogtreecommitdiffstats
path: root/server-client.c
diff options
context:
space:
mode:
authornicm <nicm>2020-05-24 09:13:06 +0000
committernicm <nicm>2020-05-24 09:13:06 +0000
commit6c829827110c6616c8abe8cb3ef9e9ed0a1dbd7d (patch)
tree5de239b7d8c9f5acf79d1eb17462c03487f0d239 /server-client.c
parent033d6472cb71e82be75aae6682031ef3b711226a (diff)
Now the tty has a pointer back to the client there is no point (and a
bit confusing) in it keeping a copy of the fd as well. Remove it.
Diffstat (limited to 'server-client.c')
-rw-r--r--server-client.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/server-client.c b/server-client.c
index d514b11e..2cf9c387 100644
--- a/server-client.c
+++ b/server-client.c
@@ -229,7 +229,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;
@@ -307,10 +306,6 @@ 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_TERMINAL)
tty_free(&c->tty);
free(c->ttyname);
@@ -342,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 */
@@ -2008,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;
@@ -2210,11 +2209,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 {