mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-23 05:33:57 -04:00
term: delayed rendering: read timers even though is_armed = false
There's a race/chance that we'll have disarmed the delayed rendering timers and still get the call. While it _shouldn't_ be anything to read from the timers, it doesn't hurt to try. And, if the timers *are* readable, not reading them means we'll end up in an infinite FDM loop.
This commit is contained in:
parent
48091966cb
commit
ba0d0e8bbb
1 changed files with 8 additions and 5 deletions
13
terminal.c
13
terminal.c
|
|
@ -396,8 +396,6 @@ fdm_delayed_render(struct fdm *fdm, int fd, int events, void *data)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
struct terminal *term = data;
|
struct terminal *term = data;
|
||||||
if (!term->delayed_render_timer.is_armed)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
uint64_t unused;
|
uint64_t unused;
|
||||||
ssize_t ret1 = 0;
|
ssize_t ret1 = 0;
|
||||||
|
|
@ -412,6 +410,9 @@ fdm_delayed_render(struct fdm *fdm, int fd, int events, void *data)
|
||||||
if (errno == EAGAIN)
|
if (errno == EAGAIN)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
if (!term->delayed_render_timer.is_armed)
|
||||||
|
return true;
|
||||||
|
|
||||||
LOG_ERRNO("failed to read timeout timer");
|
LOG_ERRNO("failed to read timeout timer");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -425,13 +426,15 @@ fdm_delayed_render(struct fdm *fdm, int fd, int events, void *data)
|
||||||
last = (struct timespec){0};
|
last = (struct timespec){0};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
render_refresh(term);
|
|
||||||
|
|
||||||
/* Reset timers */
|
/* Reset timers */
|
||||||
struct itimerspec reset = {{0}};
|
struct itimerspec reset = {{0}};
|
||||||
timerfd_settime(term->delayed_render_timer.lower_fd, 0, &reset, NULL);
|
timerfd_settime(term->delayed_render_timer.lower_fd, 0, &reset, NULL);
|
||||||
timerfd_settime(term->delayed_render_timer.upper_fd, 0, &reset, NULL);
|
timerfd_settime(term->delayed_render_timer.upper_fd, 0, &reset, NULL);
|
||||||
term->delayed_render_timer.is_armed = false;
|
|
||||||
|
if (term->delayed_render_timer.is_armed) {
|
||||||
|
term->delayed_render_timer.is_armed = false;
|
||||||
|
render_refresh(term);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue