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; }