From ff4f6b90660dd5477f1c4242f3e8628ef3854a74 Mon Sep 17 00:00:00 2001 From: nicm Date: Wed, 7 Jan 2026 20:03:34 +0000 Subject: [PATCH 1/2] Extend escape timeout if there are active forwarded requests not just tmux's own requests. GitHub issue 4793. --- tty-keys.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tty-keys.c b/tty-keys.c index 2fa05146..33de5cbb 100644 --- a/tty-keys.c +++ b/tty-keys.c @@ -956,7 +956,8 @@ partial_key: if (delay == 0) delay = 1; if ((tty->flags & (TTY_WAITFG|TTY_WAITBG) || - (tty->flags & TTY_ALL_REQUEST_FLAGS) != TTY_ALL_REQUEST_FLAGS)) { + (tty->flags & TTY_ALL_REQUEST_FLAGS) != TTY_ALL_REQUEST_FLAGS) || + !TAILQ_EMPTY(&c->input_requests)) { log_debug("%s: increasing delay for active query", c->name); if (delay < 500) delay = 500; From c8ccd420be6ff6fad19346cbc1c85ef1fe1634c7 Mon Sep 17 00:00:00 2001 From: nicm Date: Wed, 7 Jan 2026 20:16:32 +0000 Subject: [PATCH 2/2] Reduce request timeout to 500 milliseconds to match the extended escape-time, and discard palette requests if receiving a reply for a different index. --- input.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/input.c b/input.c index 43d5e9a7..45b70db6 100644 --- a/input.c +++ b/input.c @@ -63,7 +63,7 @@ struct input_request { struct input_ctx *ictx; enum input_request_type type; - time_t t; + uint64_t t; enum input_end_type end; int idx; @@ -72,7 +72,7 @@ struct input_request { TAILQ_ENTRY(input_request) entry; TAILQ_ENTRY(input_request) centry; }; -#define INPUT_REQUEST_TIMEOUT 2 +#define INPUT_REQUEST_TIMEOUT 500 /* Input parser cell. */ struct input_cell { @@ -3206,7 +3206,7 @@ input_request_timer_callback(__unused int fd, __unused short events, void *arg) { struct input_ctx *ictx = arg; struct input_request *ir, *ir1; - time_t t = time(NULL); + uint64_t t = get_timer(); TAILQ_FOREACH_SAFE(ir, &ictx->requests, entry, ir1) { if (ir->t >= t - INPUT_REQUEST_TIMEOUT) @@ -3223,7 +3223,7 @@ input_request_timer_callback(__unused int fd, __unused short events, void *arg) static void input_start_request_timer(struct input_ctx *ictx) { - struct timeval tv = { .tv_sec = 0, .tv_usec = 500000 }; + struct timeval tv = { .tv_sec = 0, .tv_usec = 100000 }; event_del(&ictx->request_timer); event_add(&ictx->request_timer, &tv); @@ -3238,7 +3238,7 @@ input_make_request(struct input_ctx *ictx, enum input_request_type type) ir = xcalloc (1, sizeof *ir); ir->type = type; ir->ictx = ictx; - ir->t = time(NULL); + ir->t = get_timer(); if (++ictx->request_count == 1) input_start_request_timer(ictx); @@ -3359,7 +3359,11 @@ input_request_reply(struct client *c, enum input_request_type type, void *data) input_free_request(ir); continue; } - if (type == INPUT_REQUEST_PALETTE && pd->idx == ir->idx) { + if (type == INPUT_REQUEST_PALETTE) { + if (pd->idx != ir->idx) { + input_free_request(ir); + continue; + } found = ir; break; }