mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
Don't use non-blocking FDs
We use epoll() to determine when we can read/write FDs so there's absolutely no need for non-blocking.
This commit is contained in:
parent
95b7c405d4
commit
2e78dcc5e5
2 changed files with 6 additions and 33 deletions
24
terminal.c
24
terminal.c
|
|
@ -310,35 +310,21 @@ term_init(const struct config *conf, struct fdm *fdm, struct wayland *wayl,
|
|||
LOG_ERRNO("failed to open PTY");
|
||||
goto close_fds;
|
||||
}
|
||||
if ((flash_fd = timerfd_create(CLOCK_BOOTTIME, TFD_CLOEXEC | TFD_NONBLOCK)) == -1) {
|
||||
if ((flash_fd = timerfd_create(CLOCK_BOOTTIME, TFD_CLOEXEC)) == -1) {
|
||||
LOG_ERRNO("failed to create flash timer FD");
|
||||
goto close_fds;
|
||||
}
|
||||
if ((blink_fd = timerfd_create(CLOCK_BOOTTIME, TFD_CLOEXEC | TFD_NONBLOCK)) == -1) {
|
||||
if ((blink_fd = timerfd_create(CLOCK_BOOTTIME, TFD_CLOEXEC)) == -1) {
|
||||
LOG_ERRNO("failed to create blink timer FD");
|
||||
goto close_fds;
|
||||
}
|
||||
if ((delay_lower_fd = timerfd_create(CLOCK_BOOTTIME, TFD_CLOEXEC | TFD_NONBLOCK)) == -1 ||
|
||||
(delay_upper_fd = timerfd_create(CLOCK_BOOTTIME, TFD_CLOEXEC | TFD_NONBLOCK)) == -1)
|
||||
if ((delay_lower_fd = timerfd_create(CLOCK_BOOTTIME, TFD_CLOEXEC)) == -1 ||
|
||||
(delay_upper_fd = timerfd_create(CLOCK_BOOTTIME, TFD_CLOEXEC)) == -1)
|
||||
{
|
||||
LOG_ERRNO("failed to create delayed rendering timer FDs");
|
||||
goto close_fds;
|
||||
}
|
||||
|
||||
/* Read logic requires non-blocking mode */
|
||||
{
|
||||
int fd_flags = fcntl(ptmx, F_GETFL);
|
||||
if (fd_flags == -1) {
|
||||
LOG_ERRNO("failed to set non blocking mode on PTY master");
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (fcntl(ptmx, F_SETFL, fd_flags | O_NONBLOCK) == -1) {
|
||||
LOG_ERRNO("failed to set non blocking mode on PTY master");
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
if (!fdm_add(fdm, ptmx, EPOLLIN, &fdm_ptmx, term)) {
|
||||
LOG_ERR("failed to add ptmx to FDM");
|
||||
goto err;
|
||||
|
|
@ -574,7 +560,7 @@ term_shutdown(struct terminal *term)
|
|||
* This is done by opening an event FD and adding it to the FDM.
|
||||
*/
|
||||
|
||||
int event_fd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
|
||||
int event_fd = eventfd(0, EFD_CLOEXEC);
|
||||
if (event_fd == -1) {
|
||||
LOG_ERRNO("failed to create terminal shutdown event FD");
|
||||
return false;
|
||||
|
|
|
|||
15
wayland.c
15
wayland.c
|
|
@ -407,9 +407,6 @@ 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;
|
||||
}
|
||||
|
|
@ -513,26 +510,16 @@ wayl_init(struct fdm *fdm)
|
|||
goto out;
|
||||
}
|
||||
|
||||
wayl->kbd.repeat.fd = timerfd_create(CLOCK_BOOTTIME, TFD_CLOEXEC | TFD_NONBLOCK);
|
||||
/* All wayland initialization done - make it so */
|
||||
wl_display_roundtrip(wayl->display);
|
||||
|
||||
wayl->kbd.repeat.fd = timerfd_create(CLOCK_BOOTTIME, TFD_CLOEXEC);
|
||||
if (wayl->kbd.repeat.fd == -1) {
|
||||
LOG_ERRNO("failed to create keyboard repeat timer FD");
|
||||
goto out;
|
||||
}
|
||||
|
||||
int wl_fd = wl_display_get_fd(wayl->display);
|
||||
int fd_flags = fcntl(wl_fd, F_GETFL);
|
||||
if (fd_flags == -1) {
|
||||
LOG_ERRNO("failed to set non blocking mode on Wayland display connection");
|
||||
goto out;
|
||||
}
|
||||
if (fcntl(wl_fd, F_SETFL, fd_flags | O_NONBLOCK) == -1) {
|
||||
LOG_ERRNO("failed to set non blocking mode on Wayland display connection");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!fdm_add(fdm, wl_fd, EPOLLIN, &fdm_wayl, wayl)) {
|
||||
LOG_ERR("failed to register Wayland connection with the FDM");
|
||||
goto out;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue