From e37f34facc05c3ba146d4158cc7af23f6886fecd Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 7 Jun 2019 20:09:17 +0000 Subject: Do not load the config file if the server is exiting because it failed to start, otherwise commands like lsk which start the server again can end up looping infinitely. Also make the first client exit correctly. Problem reported by Wael M Nasreddine. --- server.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'server.c') diff --git a/server.c b/server.c index 18818c38..fc3730ad 100644 --- a/server.c +++ b/server.c @@ -44,7 +44,7 @@ struct clients clients; struct tmuxproc *server_proc; -static int server_fd; +static int server_fd = -1; static int server_exit; static struct event server_ev_accept; @@ -208,11 +208,10 @@ server_start(struct tmuxproc *client, struct event_base *base, int lockfd, cmdq_append(c, cmdq_get_error(cause)); free(cause); c->flags |= CLIENT_EXIT; - } + } else + start_cfg(); - start_cfg(); server_add_accept(0); - proc_loop(server_proc, server_loop); job_kill_all(); @@ -364,6 +363,9 @@ server_add_accept(int timeout) { struct timeval tv = { timeout, 0 }; + if (server_fd == -1) + return; + if (event_initialized(&server_ev_accept)) event_del(&server_ev_accept); -- cgit From ae541287d303fb253b3cd75341c318dcc6a8db4a Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 20 Jun 2019 06:51:36 +0000 Subject: Expand command formats in %if and move the config file loading later (to when the first client has identified) so all the client formats are available, fixes problems reported by Thomas Sattler. --- server.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'server.c') diff --git a/server.c b/server.c index fc3730ad..e75b02da 100644 --- a/server.c +++ b/server.c @@ -208,8 +208,7 @@ server_start(struct tmuxproc *client, struct event_base *base, int lockfd, cmdq_append(c, cmdq_get_error(cause)); free(cause); c->flags |= CLIENT_EXIT; - } else - start_cfg(); + } server_add_accept(0); proc_loop(server_proc, server_loop); -- cgit