mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-30 06:46:45 -04:00
fdm: use poll(3) instead of epoll_wait(2)
poll() is more portable, and since foot doesn’t use _that_ many FDs, there should be no noticeable performance difference between the two.
This commit is contained in:
parent
e19db15104
commit
4fa4d54d2b
9 changed files with 204 additions and 165 deletions
|
|
@ -49,6 +49,7 @@
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
* Use `poll()` instead of `epoll_wait()`.
|
||||||
* The fcft and tllist library subprojects are now handled via Meson
|
* The fcft and tllist library subprojects are now handled via Meson
|
||||||
[wrap files](https://mesonbuild.com/Wrap-dependency-system-manual.html)
|
[wrap files](https://mesonbuild.com/Wrap-dependency-system-manual.html)
|
||||||
instead of needing to be manually cloned.
|
instead of needing to be manually cloned.
|
||||||
|
|
|
||||||
252
fdm.c
252
fdm.c
|
|
@ -3,11 +3,11 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <poll.h>
|
||||||
#include <sys/epoll.h>
|
|
||||||
|
|
||||||
#include <tllist.h>
|
#include <tllist.h>
|
||||||
|
|
||||||
|
|
@ -15,13 +15,16 @@
|
||||||
#define LOG_ENABLE_DBG 0
|
#define LOG_ENABLE_DBG 0
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
#include "xmalloc.h"
|
||||||
|
|
||||||
struct handler {
|
struct handler {
|
||||||
int fd;
|
enum {
|
||||||
int events;
|
HANDLER_ACTIVE,
|
||||||
|
HANDLER_DEFERRED_DELETE,
|
||||||
|
HANDLER_DEFERRED_DELETE_AND_CLOSE
|
||||||
|
} status;
|
||||||
fdm_handler_t callback;
|
fdm_handler_t callback;
|
||||||
void *callback_data;
|
void *callback_data;
|
||||||
bool deleted;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct hook {
|
struct hook {
|
||||||
|
|
@ -32,35 +35,54 @@ struct hook {
|
||||||
typedef tll(struct hook) hooks_t;
|
typedef tll(struct hook) hooks_t;
|
||||||
|
|
||||||
struct fdm {
|
struct fdm {
|
||||||
int epoll_fd;
|
/*
|
||||||
bool is_polling;
|
* Paired arrays of poll() data and the associated callbacks.
|
||||||
tll(struct handler *) fds;
|
*
|
||||||
tll(struct handler *) deferred_delete;
|
* Both arrays have <size> number of elements. The first <count>
|
||||||
|
* elements are valid/in use.
|
||||||
|
*
|
||||||
|
* <max_count> is for debugging/statistics, and tracks the maximum
|
||||||
|
* number of simultaniously active FDs.
|
||||||
|
*/
|
||||||
|
struct pollfd *fds;
|
||||||
|
struct handler *handlers;
|
||||||
|
size_t count;
|
||||||
|
size_t size;
|
||||||
|
size_t max_count;
|
||||||
|
|
||||||
hooks_t hooks_low;
|
hooks_t hooks_low;
|
||||||
hooks_t hooks_normal;
|
hooks_t hooks_normal;
|
||||||
hooks_t hooks_high;
|
hooks_t hooks_high;
|
||||||
|
bool is_polling;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const size_t min_slot_count = 32;
|
||||||
|
|
||||||
struct fdm *
|
struct fdm *
|
||||||
fdm_init(void)
|
fdm_init(void)
|
||||||
{
|
{
|
||||||
int epoll_fd = epoll_create1(EPOLL_CLOEXEC);
|
|
||||||
if (epoll_fd == -1) {
|
|
||||||
LOG_ERRNO("failed to create epoll FD");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct fdm *fdm = malloc(sizeof(*fdm));
|
struct fdm *fdm = malloc(sizeof(*fdm));
|
||||||
if (unlikely(fdm == NULL)) {
|
if (unlikely(fdm == NULL)) {
|
||||||
LOG_ERRNO("malloc() failed");
|
LOG_ERRNO("malloc() failed");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct pollfd *fds = malloc(min_slot_count * sizeof(fds[0]));
|
||||||
|
struct handler *handlers = malloc(min_slot_count * sizeof(handlers[0]));
|
||||||
|
|
||||||
|
if (fds == NULL || handlers == NULL) {
|
||||||
|
LOG_ERRNO("failed to allocate initial array of FD handlers");
|
||||||
|
free(handlers);
|
||||||
|
free(fds);
|
||||||
|
free(fdm);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
*fdm = (struct fdm){
|
*fdm = (struct fdm){
|
||||||
.epoll_fd = epoll_fd,
|
|
||||||
.is_polling = false,
|
.is_polling = false,
|
||||||
.fds = tll_init(),
|
.fds = fds,
|
||||||
.deferred_delete = tll_init(),
|
.handlers = handlers,
|
||||||
|
.size = min_slot_count,
|
||||||
.hooks_low = tll_init(),
|
.hooks_low = tll_init(),
|
||||||
.hooks_normal = tll_init(),
|
.hooks_normal = tll_init(),
|
||||||
.hooks_high = tll_init(),
|
.hooks_high = tll_init(),
|
||||||
|
|
@ -74,7 +96,9 @@ fdm_destroy(struct fdm *fdm)
|
||||||
if (fdm == NULL)
|
if (fdm == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (tll_length(fdm->fds) > 0)
|
LOG_DBG("max FDs registered: %zu", fdm->max_count);
|
||||||
|
|
||||||
|
if (fdm->count > 0)
|
||||||
LOG_WARN("FD list not empty");
|
LOG_WARN("FD list not empty");
|
||||||
|
|
||||||
if (tll_length(fdm->hooks_low) > 0 ||
|
if (tll_length(fdm->hooks_low) > 0 ||
|
||||||
|
|
@ -84,34 +108,25 @@ fdm_destroy(struct fdm *fdm)
|
||||||
LOG_WARN("hook list not empty");
|
LOG_WARN("hook list not empty");
|
||||||
}
|
}
|
||||||
|
|
||||||
xassert(tll_length(fdm->fds) == 0);
|
xassert(fdm->count == 0);
|
||||||
xassert(tll_length(fdm->deferred_delete) == 0);
|
|
||||||
xassert(tll_length(fdm->hooks_low) == 0);
|
xassert(tll_length(fdm->hooks_low) == 0);
|
||||||
xassert(tll_length(fdm->hooks_normal) == 0);
|
xassert(tll_length(fdm->hooks_normal) == 0);
|
||||||
xassert(tll_length(fdm->hooks_high) == 0);
|
xassert(tll_length(fdm->hooks_high) == 0);
|
||||||
|
|
||||||
tll_free(fdm->fds);
|
free(fdm->fds);
|
||||||
tll_free(fdm->deferred_delete);
|
free(fdm->handlers);
|
||||||
tll_free(fdm->hooks_low);
|
tll_free(fdm->hooks_low);
|
||||||
tll_free(fdm->hooks_normal);
|
tll_free(fdm->hooks_normal);
|
||||||
tll_free(fdm->hooks_high);
|
tll_free(fdm->hooks_high);
|
||||||
close(fdm->epoll_fd);
|
|
||||||
free(fdm);
|
free(fdm);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
fdm_add(struct fdm *fdm, int fd, int events, fdm_handler_t handler, void *data)
|
fdm_add(struct fdm *fdm, int fd, int events, fdm_handler_t cb, void *data)
|
||||||
{
|
{
|
||||||
#if defined(_DEBUG)
|
#if defined(_DEBUG)
|
||||||
int flags = fcntl(fd, F_GETFL);
|
for (size_t i = 0; i < fdm->count; i++) {
|
||||||
if (!(flags & O_NONBLOCK)) {
|
if (fdm->fds[i].fd == fd) {
|
||||||
LOG_ERR("FD=%d is in blocking mode", fd);
|
|
||||||
xassert(false);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
tll_foreach(fdm->fds, it) {
|
|
||||||
if (it->item->fd == fd) {
|
|
||||||
LOG_ERR("FD=%d already registered", fd);
|
LOG_ERR("FD=%d already registered", fd);
|
||||||
xassert(false);
|
xassert(false);
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -119,64 +134,85 @@ fdm_add(struct fdm *fdm, int fd, int events, fdm_handler_t handler, void *data)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct handler *fd_data = malloc(sizeof(*fd_data));
|
if (fdm->count >= fdm->size) {
|
||||||
if (unlikely(fd_data == NULL)) {
|
/* No free slot - increase number of pollfds + handlers */
|
||||||
LOG_ERRNO("malloc() failed");
|
|
||||||
return false;
|
size_t old_size = fdm->size;
|
||||||
|
size_t new_size = old_size * 2;
|
||||||
|
|
||||||
|
fdm->fds = xrealloc(fdm->fds, new_size * sizeof(fdm->fds[0]));
|
||||||
|
fdm->handlers = xrealloc(fdm->handlers, new_size * sizeof(fdm->handlers[0]));
|
||||||
|
fdm->size = new_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
*fd_data = (struct handler) {
|
xassert(fdm->count < fdm->size);
|
||||||
.fd = fd,
|
|
||||||
.events = events,
|
|
||||||
.callback = handler,
|
|
||||||
.callback_data = data,
|
|
||||||
.deleted = false,
|
|
||||||
};
|
|
||||||
|
|
||||||
tll_push_back(fdm->fds, fd_data);
|
struct pollfd *pfd = &fdm->fds[fdm->count];
|
||||||
|
struct handler *handler = &fdm->handlers[fdm->count];
|
||||||
|
|
||||||
struct epoll_event ev = {
|
pfd->fd = fd;
|
||||||
.events = events,
|
pfd->events = events;
|
||||||
.data = {.ptr = fd_data},
|
|
||||||
};
|
|
||||||
|
|
||||||
if (epoll_ctl(fdm->epoll_fd, EPOLL_CTL_ADD, fd, &ev) < 0) {
|
handler->callback = cb;
|
||||||
LOG_ERRNO("failed to register FD=%d with epoll", fd);
|
handler->callback_data = data;
|
||||||
free(fd_data);
|
handler->status = HANDLER_ACTIVE;
|
||||||
tll_pop_back(fdm->fds);
|
|
||||||
return false;
|
if (++fdm->count > fdm->max_count)
|
||||||
}
|
fdm->max_count = fdm->count;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
deferred_delete(struct fdm *fdm, size_t idx)
|
||||||
|
{
|
||||||
|
xassert(!fdm->is_polling);
|
||||||
|
xassert(idx < fdm->count);
|
||||||
|
|
||||||
|
struct handler *handler = &fdm->handlers[idx];
|
||||||
|
xassert(fdm->handlers[idx].status != HANDLER_ACTIVE);
|
||||||
|
|
||||||
|
if (handler->status == HANDLER_DEFERRED_DELETE_AND_CLOSE) {
|
||||||
|
xassert(fdm->fds[idx].fd >= 0);
|
||||||
|
close(fdm->fds[idx].fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
const size_t remaining = fdm->count - (idx + 1);
|
||||||
|
|
||||||
|
memmove(&fdm->fds[idx], &fdm->fds[idx + 1],
|
||||||
|
remaining * sizeof(fdm->fds[0]));
|
||||||
|
|
||||||
|
memmove(&fdm->handlers[idx], &fdm->handlers[idx + 1],
|
||||||
|
remaining * sizeof(fdm->handlers[0]));
|
||||||
|
|
||||||
|
fdm->count--;
|
||||||
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
fdm_del_internal(struct fdm *fdm, int fd, bool close_fd)
|
fdm_del_internal(struct fdm *fdm, int fd, bool close_fd)
|
||||||
{
|
{
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
tll_foreach(fdm->fds, it) {
|
for (size_t i = 0; i < fdm->count; i++) {
|
||||||
if (it->item->fd != fd)
|
struct pollfd *pfd = &fdm->fds[i];
|
||||||
|
struct handler *handler = &fdm->handlers[i];
|
||||||
|
|
||||||
|
if (pfd->fd != fd)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (epoll_ctl(fdm->epoll_fd, EPOLL_CTL_DEL, fd, NULL) < 0)
|
handler->status = close_fd
|
||||||
LOG_ERRNO("failed to unregister FD=%d from epoll", fd);
|
? HANDLER_DEFERRED_DELETE_AND_CLOSE
|
||||||
|
: HANDLER_DEFERRED_DELETE;
|
||||||
|
|
||||||
if (close_fd)
|
if (!fdm->is_polling)
|
||||||
close(it->item->fd);
|
deferred_delete(fdm, i);
|
||||||
|
|
||||||
it->item->deleted = true;
|
|
||||||
if (fdm->is_polling)
|
|
||||||
tll_push_back(fdm->deferred_delete, it->item);
|
|
||||||
else
|
|
||||||
free(it->item);
|
|
||||||
|
|
||||||
tll_remove(fdm->fds, it);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_ERR("no such FD: %d", fd);
|
LOG_ERR("no such FD: %d", fd);
|
||||||
|
if (close_fd)
|
||||||
close(fd);
|
close(fd);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -193,35 +229,17 @@ fdm_del_no_close(struct fdm *fdm, int fd)
|
||||||
return fdm_del_internal(fdm, fd, false);
|
return fdm_del_internal(fdm, fd, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
|
||||||
event_modify(struct fdm *fdm, struct handler *fd, int new_events)
|
|
||||||
{
|
|
||||||
if (new_events == fd->events)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
struct epoll_event ev = {
|
|
||||||
.events = new_events,
|
|
||||||
.data = {.ptr = fd},
|
|
||||||
};
|
|
||||||
|
|
||||||
if (epoll_ctl(fdm->epoll_fd, EPOLL_CTL_MOD, fd->fd, &ev) < 0) {
|
|
||||||
LOG_ERRNO("failed to modify FD=%d with epoll (events 0x%08x -> 0x%08x)",
|
|
||||||
fd->fd, fd->events, new_events);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
fd->events = new_events;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
fdm_event_add(struct fdm *fdm, int fd, int events)
|
fdm_event_add(struct fdm *fdm, int fd, int events)
|
||||||
{
|
{
|
||||||
tll_foreach(fdm->fds, it) {
|
for (size_t i = 0; i < fdm->count; i++) {
|
||||||
if (it->item->fd != fd)
|
struct pollfd *pfd = &fdm->fds[i];
|
||||||
|
|
||||||
|
if (pfd->fd != fd)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
return event_modify(fdm, it->item, it->item->events | events);
|
pfd->events |= events;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_ERR("FD=%d not registered with the FDM", fd);
|
LOG_ERR("FD=%d not registered with the FDM", fd);
|
||||||
|
|
@ -231,11 +249,14 @@ fdm_event_add(struct fdm *fdm, int fd, int events)
|
||||||
bool
|
bool
|
||||||
fdm_event_del(struct fdm *fdm, int fd, int events)
|
fdm_event_del(struct fdm *fdm, int fd, int events)
|
||||||
{
|
{
|
||||||
tll_foreach(fdm->fds, it) {
|
for (size_t i = 0; i < fdm->count; i++) {
|
||||||
if (it->item->fd != fd)
|
struct pollfd *pfd = &fdm->fds[i];
|
||||||
|
|
||||||
|
if (pfd->fd != fd)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
return event_modify(fdm, it->item, it->item->events & ~events);
|
pfd->events &= ~events;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_ERR("FD=%d not registered with the FDM", fd);
|
LOG_ERR("FD=%d not registered with the FDM", fd);
|
||||||
|
|
@ -322,35 +343,52 @@ fdm_poll(struct fdm *fdm)
|
||||||
it->item.callback(fdm, it->item.callback_data);
|
it->item.callback(fdm, it->item.callback_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct epoll_event events[tll_length(fdm->fds)];
|
int r = poll(fdm->fds, fdm->count, -1);
|
||||||
|
|
||||||
int r = epoll_wait(fdm->epoll_fd, events, tll_length(fdm->fds), -1);
|
|
||||||
if (unlikely(r < 0)) {
|
if (unlikely(r < 0)) {
|
||||||
if (errno == EINTR)
|
if (errno == EINTR)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
LOG_ERRNO("failed to epoll");
|
LOG_ERRNO("failed to poll");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
|
|
||||||
fdm->is_polling = true;
|
fdm->is_polling = true;
|
||||||
for (int i = 0; i < r; i++) {
|
for (int i = 0, matched = 0; matched < r; i++) {
|
||||||
struct handler *fd = events[i].data.ptr;
|
xassert(i < fdm->count);
|
||||||
if (fd->deleted)
|
|
||||||
|
struct pollfd *pfd = &fdm->fds[i];
|
||||||
|
if (pfd->revents == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!fd->callback(fdm, fd->fd, events[i].events, fd->callback_data)) {
|
matched++;
|
||||||
|
|
||||||
|
struct handler *handler = &fdm->handlers[i];
|
||||||
|
if (handler->status == HANDLER_ACTIVE) {
|
||||||
|
if (!handler->callback(
|
||||||
|
fdm, pfd->fd, pfd->revents, handler->callback_data))
|
||||||
|
{
|
||||||
ret = false;
|
ret = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fdm->is_polling = false;
|
fdm->is_polling = false;
|
||||||
|
|
||||||
tll_foreach(fdm->deferred_delete, it) {
|
size_t count = fdm->count;
|
||||||
free(it->item);
|
size_t i = 0;
|
||||||
tll_remove(fdm->deferred_delete, it);
|
|
||||||
|
while (i < count) {
|
||||||
|
struct handler *handler = &fdm->handlers[i];
|
||||||
|
if (handler->status == HANDLER_ACTIVE) {
|
||||||
|
i++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
deferred_delete(fdm, i);
|
||||||
|
count--;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
||||||
10
input.c
10
input.c
|
|
@ -6,10 +6,10 @@
|
||||||
#include <threads.h>
|
#include <threads.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <poll.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/timerfd.h>
|
#include <sys/timerfd.h>
|
||||||
#include <sys/epoll.h>
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
#include <linux/input-event-codes.h>
|
#include <linux/input-event-codes.h>
|
||||||
|
|
@ -51,10 +51,10 @@ fdm_write_pipe(struct fdm *fdm, int fd, int events, void *data)
|
||||||
{
|
{
|
||||||
struct pipe_context *ctx = data;
|
struct pipe_context *ctx = data;
|
||||||
|
|
||||||
if (events & EPOLLHUP)
|
if (events & POLLHUP)
|
||||||
goto pipe_closed;
|
goto pipe_closed;
|
||||||
|
|
||||||
xassert(events & EPOLLOUT);
|
xassert(events & POLLOUT);
|
||||||
ssize_t written = write(fd, &ctx->text[ctx->idx], ctx->left);
|
ssize_t written = write(fd, &ctx->text[ctx->idx], ctx->left);
|
||||||
|
|
||||||
if (written < 0) {
|
if (written < 0) {
|
||||||
|
|
@ -253,7 +253,7 @@ execute_binding(struct seat *seat, struct terminal *term,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Asynchronously write the output to the pipe */
|
/* Asynchronously write the output to the pipe */
|
||||||
if (!fdm_add(term->fdm, pipe_fd[1], EPOLLOUT, &fdm_write_pipe, ctx))
|
if (!fdm_add(term->fdm, pipe_fd[1], POLLOUT, &fdm_write_pipe, ctx))
|
||||||
goto pipe_err;
|
goto pipe_err;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -1611,7 +1611,7 @@ wl_pointer_button(void *data, struct wl_pointer *wl_pointer,
|
||||||
int fd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK);
|
int fd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK);
|
||||||
if (fd >= 0 &&
|
if (fd >= 0 &&
|
||||||
timerfd_settime(fd, 0, &timeout, NULL) == 0 &&
|
timerfd_settime(fd, 0, &timeout, NULL) == 0 &&
|
||||||
fdm_add(wayl->fdm, fd, EPOLLIN, &fdm_csd_move, seat))
|
fdm_add(wayl->fdm, fd, POLLIN, &fdm_csd_move, seat))
|
||||||
{
|
{
|
||||||
win->csd.move_timeout_fd = fd;
|
win->csd.move_timeout_fd = fd;
|
||||||
win->csd.serial = serial;
|
win->csd.serial = serial;
|
||||||
|
|
|
||||||
8
reaper.c
8
reaper.c
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/epoll.h>
|
#include <poll.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <sys/signalfd.h>
|
#include <sys/signalfd.h>
|
||||||
#include <tllist.h>
|
#include <tllist.h>
|
||||||
|
|
@ -60,7 +60,7 @@ reaper_init(struct fdm *fdm)
|
||||||
.children = tll_init(),
|
.children = tll_init(),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!fdm_add(fdm, fd, EPOLLIN, &fdm_reap, reaper)){
|
if (!fdm_add(fdm, fd, POLLIN, &fdm_reap, reaper)){
|
||||||
LOG_ERR("failed to register with the FDM");
|
LOG_ERR("failed to register with the FDM");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
@ -115,8 +115,8 @@ fdm_reap(struct fdm *fdm, int fd, int events, void *data)
|
||||||
{
|
{
|
||||||
struct reaper *reaper = data;
|
struct reaper *reaper = data;
|
||||||
|
|
||||||
bool pollin = events & EPOLLIN;
|
bool pollin = events & POLLIN;
|
||||||
bool hup = events & EPOLLHUP;
|
bool hup = events & POLLHUP;
|
||||||
|
|
||||||
if (hup && !pollin)
|
if (hup && !pollin)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
6
render.c
6
render.c
|
|
@ -3,11 +3,11 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <wctype.h>
|
#include <wctype.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <poll.h>
|
||||||
|
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/timerfd.h>
|
#include <sys/timerfd.h>
|
||||||
#include <sys/epoll.h>
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
#include "macros.h"
|
#include "macros.h"
|
||||||
|
|
@ -2727,7 +2727,7 @@ fdm_tiocswinsz(struct fdm *fdm, int fd, int events, void *data)
|
||||||
{
|
{
|
||||||
struct terminal *term = data;
|
struct terminal *term = data;
|
||||||
|
|
||||||
if (events & EPOLLIN)
|
if (events & POLLIN)
|
||||||
tiocswinsz(term);
|
tiocswinsz(term);
|
||||||
|
|
||||||
fdm_del(fdm, fd);
|
fdm_del(fdm, fd);
|
||||||
|
|
@ -2762,7 +2762,7 @@ send_dimensions_to_client(struct terminal *term)
|
||||||
fd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK);
|
fd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
LOG_ERRNO("failed to create TIOCSWINSZ timer");
|
LOG_ERRNO("failed to create TIOCSWINSZ timer");
|
||||||
else if (!fdm_add(term->fdm, fd, EPOLLIN, &fdm_tiocswinsz, term)) {
|
else if (!fdm_add(term->fdm, fd, POLLIN, &fdm_tiocswinsz, term)) {
|
||||||
close(fd);
|
close(fd);
|
||||||
fd = -1;
|
fd = -1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
22
selection.c
22
selection.c
|
|
@ -6,8 +6,8 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <wctype.h>
|
#include <wctype.h>
|
||||||
|
#include <poll.h>
|
||||||
|
|
||||||
#include <sys/epoll.h>
|
|
||||||
#include <sys/timerfd.h>
|
#include <sys/timerfd.h>
|
||||||
|
|
||||||
#define LOG_MODULE "selection"
|
#define LOG_MODULE "selection"
|
||||||
|
|
@ -1106,7 +1106,7 @@ selection_primary_unset(struct seat *seat)
|
||||||
static bool
|
static bool
|
||||||
fdm_scroll_timer(struct fdm *fdm, int fd, int events, void *data)
|
fdm_scroll_timer(struct fdm *fdm, int fd, int events, void *data)
|
||||||
{
|
{
|
||||||
if (events & EPOLLHUP)
|
if (events & POLLHUP)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
struct terminal *term = data;
|
struct terminal *term = data;
|
||||||
|
|
@ -1159,7 +1159,7 @@ selection_start_scroll_timer(struct terminal *term, int interval_ns,
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fdm_add(term->fdm, fd, EPOLLIN, &fdm_scroll_timer, term)) {
|
if (!fdm_add(term->fdm, fd, POLLIN, &fdm_scroll_timer, term)) {
|
||||||
close(fd);
|
close(fd);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -1223,7 +1223,7 @@ fdm_send(struct fdm *fdm, int fd, int events, void *data)
|
||||||
{
|
{
|
||||||
struct clipboard_send *ctx = data;
|
struct clipboard_send *ctx = data;
|
||||||
|
|
||||||
if (events & EPOLLHUP)
|
if (events & POLLHUP)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
switch (async_write(fd, ctx->data, ctx->len, &ctx->idx)) {
|
switch (async_write(fd, ctx->data, ctx->len, &ctx->idx)) {
|
||||||
|
|
@ -1273,7 +1273,7 @@ send_clipboard_or_primary(struct seat *seat, int fd, const char *selection,
|
||||||
.idx = 0,
|
.idx = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (fdm_add(seat->wayl->fdm, fd, EPOLLOUT, &fdm_send, ctx))
|
if (fdm_add(seat->wayl->fdm, fd, POLLOUT, &fdm_send, ctx))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
free(ctx->data);
|
free(ctx->data);
|
||||||
|
|
@ -1471,10 +1471,10 @@ static bool
|
||||||
fdm_receive_timeout(struct fdm *fdm, int fd, int events, void *data)
|
fdm_receive_timeout(struct fdm *fdm, int fd, int events, void *data)
|
||||||
{
|
{
|
||||||
struct clipboard_receive *ctx = data;
|
struct clipboard_receive *ctx = data;
|
||||||
if (events & EPOLLHUP)
|
if (events & POLLHUP)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
xassert(events & EPOLLIN);
|
xassert(events & POLLIN);
|
||||||
|
|
||||||
uint64_t expire_count;
|
uint64_t expire_count;
|
||||||
ssize_t ret = read(fd, &expire_count, sizeof(expire_count));
|
ssize_t ret = read(fd, &expire_count, sizeof(expire_count));
|
||||||
|
|
@ -1582,7 +1582,7 @@ fdm_receive(struct fdm *fdm, int fd, int events, void *data)
|
||||||
{
|
{
|
||||||
struct clipboard_receive *ctx = data;
|
struct clipboard_receive *ctx = data;
|
||||||
|
|
||||||
if ((events & EPOLLHUP) && !(events & EPOLLIN))
|
if ((events & POLLHUP) && !(events & POLLIN))
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
/* Reset timeout timer */
|
/* Reset timeout timer */
|
||||||
|
|
@ -1716,8 +1716,8 @@ begin_receive_clipboard(struct terminal *term, int read_fd,
|
||||||
.user = user,
|
.user = user,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!fdm_add(term->fdm, read_fd, EPOLLIN, &fdm_receive, ctx) ||
|
if (!fdm_add(term->fdm, read_fd, POLLIN, &fdm_receive, ctx) ||
|
||||||
!fdm_add(term->fdm, timeout_fd, EPOLLIN, &fdm_receive_timeout, ctx))
|
!fdm_add(term->fdm, timeout_fd, POLLIN, &fdm_receive_timeout, ctx))
|
||||||
{
|
{
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
@ -1787,7 +1787,7 @@ receive_offer_done(void *user)
|
||||||
|
|
||||||
/* Make sure we send any queued up non-paste data */
|
/* Make sure we send any queued up non-paste data */
|
||||||
if (tll_length(term->ptmx_buffers) > 0)
|
if (tll_length(term->ptmx_buffers) > 0)
|
||||||
fdm_event_add(term->fdm, term->ptmx, EPOLLOUT);
|
fdm_event_add(term->fdm, term->ptmx, POLLOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
12
server.c
12
server.c
|
|
@ -3,10 +3,10 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <poll.h>
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/epoll.h>
|
|
||||||
|
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
|
|
||||||
|
|
@ -120,10 +120,10 @@ fdm_client(struct fdm *fdm, int fd, int events, void *data)
|
||||||
|
|
||||||
char **argv = NULL;
|
char **argv = NULL;
|
||||||
|
|
||||||
if (events & EPOLLHUP)
|
if (events & POLLHUP)
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
|
|
||||||
xassert(events & EPOLLIN);
|
xassert(events & POLLIN);
|
||||||
|
|
||||||
if (client->term != NULL) {
|
if (client->term != NULL) {
|
||||||
uint8_t dummy[128];
|
uint8_t dummy[128];
|
||||||
|
|
@ -299,7 +299,7 @@ shutdown:
|
||||||
static bool
|
static bool
|
||||||
fdm_server(struct fdm *fdm, int fd, int events, void *data)
|
fdm_server(struct fdm *fdm, int fd, int events, void *data)
|
||||||
{
|
{
|
||||||
if (events & EPOLLHUP)
|
if (events & POLLHUP)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
struct server *server = data;
|
struct server *server = data;
|
||||||
|
|
@ -320,7 +320,7 @@ fdm_server(struct fdm *fdm, int fd, int events, void *data)
|
||||||
.fd = client_fd,
|
.fd = client_fd,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!fdm_add(server->fdm, client_fd, EPOLLIN, &fdm_client, client)) {
|
if (!fdm_add(server->fdm, client_fd, POLLIN, &fdm_client, client)) {
|
||||||
close(client_fd);
|
close(client_fd);
|
||||||
free(client);
|
free(client);
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -422,7 +422,7 @@ server_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper,
|
||||||
.clients = tll_init(),
|
.clients = tll_init(),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!fdm_add(fdm, fd, EPOLLIN, &fdm_server, server))
|
if (!fdm_add(fdm, fd, POLLIN, &fdm_server, server))
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
LOG_INFO("accepting connections on %s", sock_path);
|
LOG_INFO("accepting connections on %s", sock_path);
|
||||||
|
|
|
||||||
38
terminal.c
38
terminal.c
|
|
@ -7,11 +7,11 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <poll.h>
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/epoll.h>
|
|
||||||
#include <sys/eventfd.h>
|
#include <sys/eventfd.h>
|
||||||
#include <sys/timerfd.h>
|
#include <sys/timerfd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
@ -84,7 +84,7 @@ data_to_slave(struct terminal *term, const void *data, size_t len,
|
||||||
switch (async_write(term->ptmx, data, len, &async_idx)) {
|
switch (async_write(term->ptmx, data, len, &async_idx)) {
|
||||||
case ASYNC_WRITE_REMAIN:
|
case ASYNC_WRITE_REMAIN:
|
||||||
/* Switch to asynchronous mode; let FDM write the remaining data */
|
/* Switch to asynchronous mode; let FDM write the remaining data */
|
||||||
if (!fdm_event_add(term->fdm, term->ptmx, EPOLLOUT))
|
if (!fdm_event_add(term->fdm, term->ptmx, POLLOUT))
|
||||||
return false;
|
return false;
|
||||||
enqueue_data_for_slave(data, len, async_idx, buffer_list);
|
enqueue_data_for_slave(data, len, async_idx, buffer_list);
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -196,7 +196,7 @@ fdm_ptmx_out(struct fdm *fdm, int fd, int events, void *data)
|
||||||
* otherwise we'd just be called right away again, with nothing to
|
* otherwise we'd just be called right away again, with nothing to
|
||||||
* write.
|
* write.
|
||||||
*/
|
*/
|
||||||
fdm_event_del(term->fdm, term->ptmx, EPOLLOUT);
|
fdm_event_del(term->fdm, term->ptmx, POLLOUT);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -213,9 +213,9 @@ fdm_ptmx(struct fdm *fdm, int fd, int events, void *data)
|
||||||
{
|
{
|
||||||
struct terminal *term = data;
|
struct terminal *term = data;
|
||||||
|
|
||||||
const bool pollin = events & EPOLLIN;
|
const bool pollin = events & POLLIN;
|
||||||
const bool pollout = events & EPOLLOUT;
|
const bool pollout = events & POLLOUT;
|
||||||
const bool hup = events & EPOLLHUP;
|
const bool hup = events & POLLHUP;
|
||||||
|
|
||||||
if (pollout) {
|
if (pollout) {
|
||||||
if (!fdm_ptmx_out(fdm, fd, events, data))
|
if (!fdm_ptmx_out(fdm, fd, events, data))
|
||||||
|
|
@ -330,7 +330,7 @@ fdm_ptmx(struct fdm *fdm, int fd, int events, void *data)
|
||||||
static bool
|
static bool
|
||||||
fdm_flash(struct fdm *fdm, int fd, int events, void *data)
|
fdm_flash(struct fdm *fdm, int fd, int events, void *data)
|
||||||
{
|
{
|
||||||
if (events & EPOLLHUP)
|
if (events & POLLHUP)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
struct terminal *term = data;
|
struct terminal *term = data;
|
||||||
|
|
@ -358,7 +358,7 @@ fdm_flash(struct fdm *fdm, int fd, int events, void *data)
|
||||||
static bool
|
static bool
|
||||||
fdm_blink(struct fdm *fdm, int fd, int events, void *data)
|
fdm_blink(struct fdm *fdm, int fd, int events, void *data)
|
||||||
{
|
{
|
||||||
if (events & EPOLLHUP)
|
if (events & POLLHUP)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
struct terminal *term = data;
|
struct terminal *term = data;
|
||||||
|
|
@ -421,7 +421,7 @@ term_arm_blink_timer(struct terminal *term)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fdm_add(term->fdm, fd, EPOLLIN, &fdm_blink, term)) {
|
if (!fdm_add(term->fdm, fd, POLLIN, &fdm_blink, term)) {
|
||||||
close(fd);
|
close(fd);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -450,7 +450,7 @@ cursor_refresh(struct terminal *term)
|
||||||
static bool
|
static bool
|
||||||
fdm_cursor_blink(struct fdm *fdm, int fd, int events, void *data)
|
fdm_cursor_blink(struct fdm *fdm, int fd, int events, void *data)
|
||||||
{
|
{
|
||||||
if (events & EPOLLHUP)
|
if (events & POLLHUP)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
struct terminal *term = data;
|
struct terminal *term = data;
|
||||||
|
|
@ -480,7 +480,7 @@ fdm_cursor_blink(struct fdm *fdm, int fd, int events, void *data)
|
||||||
static bool
|
static bool
|
||||||
fdm_delayed_render(struct fdm *fdm, int fd, int events, void *data)
|
fdm_delayed_render(struct fdm *fdm, int fd, int events, void *data)
|
||||||
{
|
{
|
||||||
if (events & EPOLLHUP)
|
if (events & POLLHUP)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
struct terminal *term = data;
|
struct terminal *term = data;
|
||||||
|
|
@ -528,7 +528,7 @@ static bool
|
||||||
fdm_app_sync_updates_timeout(
|
fdm_app_sync_updates_timeout(
|
||||||
struct fdm *fdm, int fd, int events, void *data)
|
struct fdm *fdm, int fd, int events, void *data)
|
||||||
{
|
{
|
||||||
if (events & EPOLLHUP)
|
if (events & POLLHUP)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
struct terminal *term = data;
|
struct terminal *term = data;
|
||||||
|
|
@ -1063,10 +1063,10 @@ term_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper,
|
||||||
* size (and thus no grid) before then.
|
* size (and thus no grid) before then.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!fdm_add(fdm, flash_fd, EPOLLIN, &fdm_flash, term) ||
|
if (!fdm_add(fdm, flash_fd, POLLIN, &fdm_flash, term) ||
|
||||||
!fdm_add(fdm, delay_lower_fd, EPOLLIN, &fdm_delayed_render, term) ||
|
!fdm_add(fdm, delay_lower_fd, POLLIN, &fdm_delayed_render, term) ||
|
||||||
!fdm_add(fdm, delay_upper_fd, EPOLLIN, &fdm_delayed_render, term) ||
|
!fdm_add(fdm, delay_upper_fd, POLLIN, &fdm_delayed_render, term) ||
|
||||||
!fdm_add(fdm, app_sync_updates_fd, EPOLLIN, &fdm_app_sync_updates_timeout, term))
|
!fdm_add(fdm, app_sync_updates_fd, POLLIN, &fdm_app_sync_updates_timeout, term))
|
||||||
{
|
{
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
@ -1274,7 +1274,7 @@ term_window_configured(struct terminal *term)
|
||||||
/* Enable ptmx FDM callback */
|
/* Enable ptmx FDM callback */
|
||||||
if (!term->is_shutting_down) {
|
if (!term->is_shutting_down) {
|
||||||
xassert(term->window->is_configured);
|
xassert(term->window->is_configured);
|
||||||
fdm_add(term->fdm, term->ptmx, EPOLLIN, &fdm_ptmx, term);
|
fdm_add(term->fdm, term->ptmx, POLLIN, &fdm_ptmx, term);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1362,7 +1362,7 @@ term_shutdown(struct terminal *term)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fdm_add(term->fdm, event_fd, EPOLLIN, &fdm_shutdown, term)) {
|
if (!fdm_add(term->fdm, event_fd, POLLIN, &fdm_shutdown, term)) {
|
||||||
close(event_fd);
|
close(event_fd);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -2038,7 +2038,7 @@ cursor_blink_rearm_timer(struct terminal *term)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fdm_add(term->fdm, fd, EPOLLIN, &fdm_cursor_blink, term)) {
|
if (!fdm_add(term->fdm, fd, POLLIN, &fdm_cursor_blink, term)) {
|
||||||
close(fd);
|
close(fd);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
12
wayland.c
12
wayland.c
|
|
@ -6,9 +6,9 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <poll.h>
|
||||||
|
|
||||||
#include <sys/timerfd.h>
|
#include <sys/timerfd.h>
|
||||||
#include <sys/epoll.h>
|
|
||||||
|
|
||||||
#include <wayland-client.h>
|
#include <wayland-client.h>
|
||||||
#include <wayland-cursor.h>
|
#include <wayland-cursor.h>
|
||||||
|
|
@ -770,7 +770,7 @@ static const struct zxdg_toplevel_decoration_v1_listener xdg_toplevel_decoration
|
||||||
static bool
|
static bool
|
||||||
fdm_repeat(struct fdm *fdm, int fd, int events, void *data)
|
fdm_repeat(struct fdm *fdm, int fd, int events, void *data)
|
||||||
{
|
{
|
||||||
if (events & EPOLLHUP)
|
if (events & POLLHUP)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
struct seat *seat = data;
|
struct seat *seat = data;
|
||||||
|
|
@ -879,7 +879,7 @@ handle_global(void *data, struct wl_registry *registry,
|
||||||
|
|
||||||
struct seat *seat = &tll_back(wayl->seats);
|
struct seat *seat = &tll_back(wayl->seats);
|
||||||
|
|
||||||
if (!fdm_add(wayl->fdm, repeat_fd, EPOLLIN, &fdm_repeat, seat)) {
|
if (!fdm_add(wayl->fdm, repeat_fd, POLLIN, &fdm_repeat, seat)) {
|
||||||
close(repeat_fd);
|
close(repeat_fd);
|
||||||
seat->kbd.repeat.fd = -1;
|
seat->kbd.repeat.fd = -1;
|
||||||
seat_destroy(seat);
|
seat_destroy(seat);
|
||||||
|
|
@ -1092,7 +1092,7 @@ fdm_wayl(struct fdm *fdm, int fd, int events, void *data)
|
||||||
struct wayland *wayl = data;
|
struct wayland *wayl = data;
|
||||||
int event_count = 0;
|
int event_count = 0;
|
||||||
|
|
||||||
if (events & EPOLLIN) {
|
if (events & POLLIN) {
|
||||||
if (wl_display_read_events(wayl->display) < 0) {
|
if (wl_display_read_events(wayl->display) < 0) {
|
||||||
LOG_ERRNO("failed to read events from the Wayland socket");
|
LOG_ERRNO("failed to read events from the Wayland socket");
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -1102,7 +1102,7 @@ fdm_wayl(struct fdm *fdm, int fd, int events, void *data)
|
||||||
wl_display_dispatch_pending(wayl->display);
|
wl_display_dispatch_pending(wayl->display);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (events & EPOLLHUP) {
|
if (events & POLLHUP) {
|
||||||
LOG_WARN("disconnected from Wayland");
|
LOG_WARN("disconnected from Wayland");
|
||||||
wl_display_cancel_read(wayl->display);
|
wl_display_cancel_read(wayl->display);
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -1206,7 +1206,7 @@ wayl_init(const struct config *conf, struct fdm *fdm)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fdm_add(fdm, wayl->fd, EPOLLIN, &fdm_wayl, wayl))
|
if (!fdm_add(fdm, wayl->fd, POLLIN, &fdm_wayl, wayl))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (wl_display_prepare_read(wayl->display) != 0) {
|
if (wl_display_prepare_read(wayl->display) != 0) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue