summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicm <nicm>2017-04-25 14:46:23 +0000
committernicm <nicm>2017-04-25 14:46:23 +0000
commit4a51a9d9d5b43f6b576692f9ce5f5ccfa425f806 (patch)
treedc11be1fd85cea5866a08b5c7e03459b8357011d
parenteb6fd6ff80af989ca5a2d5161f6b8de460f4c575 (diff)
Block the initial client if there is one until the configuration file
has finished loading.
-rw-r--r--cfg.c38
1 files changed, 31 insertions, 7 deletions
diff --git a/cfg.c b/cfg.c
index f98d5f0b..9ade397e 100644
--- a/cfg.c
+++ b/cfg.c
@@ -28,10 +28,19 @@
#include "tmux.h"
-static char *cfg_file;
-int cfg_finished;
-static char **cfg_causes;
-static u_int cfg_ncauses;
+static char *cfg_file;
+int cfg_finished;
+static char **cfg_causes;
+static u_int cfg_ncauses;
+static struct cmdq_item *cfg_item;
+
+static enum cmd_retval
+cfg_client_done(__unused struct cmdq_item *item, __unused void *data)
+{
+ if (!cfg_finished)
+ return (CMD_RETURN_WAIT);
+ return (CMD_RETURN_NORMAL);
+}
static enum cmd_retval
cfg_done(__unused struct cmdq_item *item, __unused void *data)
@@ -43,6 +52,9 @@ cfg_done(__unused struct cmdq_item *item, __unused void *data)
if (!RB_EMPTY(&sessions))
cfg_show_causes(RB_MIN(sessions, &sessions));
+ if (cfg_item != NULL)
+ cfg_item->flags &= ~CMDQ_WAITING;
+
status_prompt_load_history();
return (CMD_RETURN_NORMAL);
@@ -60,12 +72,24 @@ start_cfg(void)
{
const char *home;
int quiet = 0;
+ struct client *c;
/*
- * Note that the configuration files are loaded without a client, so
- * NULL is passed into load_cfg() which means that commands run in the
- * global queue and item->client is NULL for all commands.
+ * Configuration files are loaded without a client, so NULL is passed
+ * into load_cfg() and commands run in the global queue with
+ * item->client NULL.
+ *
+ * However, we must block the initial client (but just the initial
+ * client) so that its command runs after the configuration is loaded.
+ * Because start_cfg() is called so early, we can be sure the client's
+ * command queue is currently empty and our callback will be at the
+ * front - we need to get in before MSG_COMMAND.
*/
+ c = TAILQ_FIRST(&clients);
+ if (c != NULL) {
+ cfg_item = cmdq_get_callback(cfg_client_done, NULL);
+ cmdq_append(c, cfg_item);
+ }
load_cfg(TMUX_CONF, NULL, NULL, 1);