mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-11-16 13:08:25 +00:00
Round up poll timeout in the I/O loop
Truncating to ms made the loop spin with a zero timeout until the deadline.
This commit is contained in:
parent
7468112c0b
commit
3a294df4da
2 changed files with 8 additions and 1 deletions
|
|
@ -1854,7 +1854,7 @@ io_loop(void *data) {
|
|||
if (has_pending_wakeups) {
|
||||
now = monotonic();
|
||||
monotonic_t time_delta = OPT(input_delay) - (now - last_main_loop_wakeup_at);
|
||||
if (time_delta >= 0) ret = poll(children_fds, self->count + EXTRA_FDS, monotonic_t_to_ms(time_delta));
|
||||
if (time_delta >= 0) ret = poll(children_fds, self->count + EXTRA_FDS, monotonic_t_to_ms_ceil(time_delta));
|
||||
else ret = 0;
|
||||
} else {
|
||||
ret = poll(children_fds, self->count + EXTRA_FDS, -1);
|
||||
|
|
@ -2032,7 +2032,9 @@ accept_peer(int listen_fd, bool shutting_down, bool is_remote_control_peer, bool
|
|||
return true;
|
||||
}
|
||||
}
|
||||
talk_mutex(lock);
|
||||
add_peer(peer, is_remote_control_peer);
|
||||
talk_mutex(unlock);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,6 +43,11 @@ monotonic_t_to_ms(monotonic_t time) {
|
|||
return (int)(time / MONOTONIC_T_1e6);
|
||||
}
|
||||
|
||||
static inline int
|
||||
monotonic_t_to_ms_ceil(monotonic_t time) {
|
||||
return (int)((time + MONOTONIC_T_1e6 - 1) / MONOTONIC_T_1e6);
|
||||
}
|
||||
|
||||
static inline int
|
||||
monotonic_t_to_us(monotonic_t time) {
|
||||
return (int)(time / MONOTONIC_T_1e3);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue