mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
timerfd: read() returns -1 with errno == EAGAIN, not 0
When there hasn't been a timeout (or in our case, there was a timeout, but we reset the timer before we got to the read()), read() returns, not 0, but -1 with errno == EAGAIN.
This commit is contained in:
parent
6ed97a47be
commit
f28fb6c039
2 changed files with 12 additions and 20 deletions
24
terminal.c
24
terminal.c
|
|
@ -113,15 +113,13 @@ fdm_flash(struct fdm *fdm, int fd, int events, void *data)
|
|||
term->flash.fd, &expiration_count, sizeof(expiration_count));
|
||||
|
||||
if (ret < 0) {
|
||||
if (errno == EAGAIN)
|
||||
return true;
|
||||
|
||||
LOG_ERRNO("failed to read flash timer");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
/* Cancelled by other handler in *this* epoll() iteration */
|
||||
return true;
|
||||
}
|
||||
|
||||
LOG_DBG("flash timer expired %llu times",
|
||||
(unsigned long long)expiration_count);
|
||||
|
||||
|
|
@ -143,15 +141,13 @@ fdm_blink(struct fdm *fdm, int fd, int events, void *data)
|
|||
term->blink.fd, &expiration_count, sizeof(expiration_count));
|
||||
|
||||
if (ret < 0) {
|
||||
if (errno == EAGAIN)
|
||||
return true;
|
||||
|
||||
LOG_ERRNO("failed to read blink timer");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
/* Cancelled by other handler in *this* epoll() iteration */
|
||||
return true;
|
||||
}
|
||||
|
||||
LOG_DBG("blink timer expired %llu times",
|
||||
(unsigned long long)expiration_count);
|
||||
|
||||
|
|
@ -195,15 +191,13 @@ fdm_delayed_render(struct fdm *fdm, int fd, int events, void *data)
|
|||
ret2 = read(term->delayed_render_timer.upper_fd, &unused, sizeof(unused));
|
||||
|
||||
if ((ret1 < 0 || ret2 < 0)) {
|
||||
if (errno == EAGAIN)
|
||||
return true;
|
||||
|
||||
LOG_ERRNO("failed to read timeout timer");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ret1 == 0 && ret2 == 0) {
|
||||
/* Cancelled by other handler in *this* epoll() iteration */
|
||||
return true;
|
||||
}
|
||||
|
||||
render_refresh(term);
|
||||
|
||||
/* Reset timers */
|
||||
|
|
|
|||
|
|
@ -407,15 +407,13 @@ fdm_repeat(struct fdm *fdm, int fd, int events, void *data)
|
|||
wayl->kbd.repeat.fd, &expiration_count, sizeof(expiration_count));
|
||||
|
||||
if (ret < 0) {
|
||||
if (errno == EAGAIN)
|
||||
return true;
|
||||
|
||||
LOG_ERRNO("failed to read repeat key from repeat timer fd");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
/* Cancelled by other handler in *this* epoll() iteration */
|
||||
return true;
|
||||
}
|
||||
|
||||
wayl->kbd.repeat.dont_re_repeat = true;
|
||||
for (size_t i = 0; i < expiration_count; i++)
|
||||
input_repeat(wayl, wayl->kbd.repeat.key);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue