Reduce request timeout to 500 milliseconds to match the extended

escape-time, and discard palette requests if receiving a reply for a
different index.
This commit is contained in:
nicm
2026-01-07 20:16:32 +00:00
parent ff4f6b9066
commit c8ccd420be

16
input.c
View File

@@ -63,7 +63,7 @@ struct input_request {
struct input_ctx *ictx; struct input_ctx *ictx;
enum input_request_type type; enum input_request_type type;
time_t t; uint64_t t;
enum input_end_type end; enum input_end_type end;
int idx; int idx;
@@ -72,7 +72,7 @@ struct input_request {
TAILQ_ENTRY(input_request) entry; TAILQ_ENTRY(input_request) entry;
TAILQ_ENTRY(input_request) centry; TAILQ_ENTRY(input_request) centry;
}; };
#define INPUT_REQUEST_TIMEOUT 2 #define INPUT_REQUEST_TIMEOUT 500
/* Input parser cell. */ /* Input parser cell. */
struct input_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_ctx *ictx = arg;
struct input_request *ir, *ir1; struct input_request *ir, *ir1;
time_t t = time(NULL); uint64_t t = get_timer();
TAILQ_FOREACH_SAFE(ir, &ictx->requests, entry, ir1) { TAILQ_FOREACH_SAFE(ir, &ictx->requests, entry, ir1) {
if (ir->t >= t - INPUT_REQUEST_TIMEOUT) 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 static void
input_start_request_timer(struct input_ctx *ictx) 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_del(&ictx->request_timer);
event_add(&ictx->request_timer, &tv); 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 = xcalloc (1, sizeof *ir);
ir->type = type; ir->type = type;
ir->ictx = ictx; ir->ictx = ictx;
ir->t = time(NULL); ir->t = get_timer();
if (++ictx->request_count == 1) if (++ictx->request_count == 1)
input_start_request_timer(ictx); 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); input_free_request(ir);
continue; 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; found = ir;
break; break;
} }