Fix prior for epoll.

This commit is contained in:
Roy Marples 2021-02-02 15:10:20 +00:00
parent 5d619328bf
commit 3c26587f67
3 changed files with 11 additions and 9 deletions

View File

@ -167,10 +167,13 @@ dev_start1(struct dhcpcd_ctx *ctx, const struct dev_dhcpcd *dev_dhcpcd)
}
static void
dev_handle_data(void *arg)
dev_handle_data(void *arg, unsigned short events)
{
struct dhcpcd_ctx *ctx;
if (events != ELE_READ)
logerrx("%s: unexpected event 0x%04x", __func__, events);
ctx = arg;
if (ctx->dev->handle_device(arg) == -1) {
/* XXX: an error occured. should we restart dev? */
@ -191,7 +194,7 @@ dev_start(struct dhcpcd_ctx *ctx, int (*handler)(void *, int, const char *))
ctx->dev_fd = dev_start1(ctx, &dev_dhcpcd);
if (ctx->dev_fd != -1) {
if (eloop_event_add(ctx->eloop, ctx->dev_fd,
if (eloop_event_add(ctx->eloop, ctx->dev_fd, ELE_READ,
dev_handle_data, ctx) == -1)
{
logerr(__func__);

View File

@ -377,13 +377,12 @@ eloop_event_add(struct eloop *eloop, int fd, unsigned short events,
#elif defined(HAVE_EPOLL)
memset(&epe, 0, sizeof(epe));
epe.data.ptr = e;
if (e->events & ELE_READ)
if (events & ELE_READ)
epe.events |= EPOLLIN;
if (e->events & ELE_WRITE)
if (events & ELE_WRITE)
epe.events |= EPOLLOUT;
op = added ? EPOLL_CTL_ADD : EPOLL_CTL_MOD;
if (epoll_ctl(eloop->fd, op, fd, &epe) == -1) {
if (epe.events != 0 && epoll_ctl(eloop->fd, op, fd, &epe) == -1) {
if (added) {
TAILQ_REMOVE(&eloop->events, e, next);
TAILQ_INSERT_TAIL(&eloop->free_events, e, next);
@ -689,9 +688,9 @@ eloop_forked(struct eloop *eloop)
#elif defined(HAVE_EPOLL)
memset(&epe, 0, sizeof(epe));
epe.data.ptr = e;
if (e->read_cb != NULL)
if (e->events & ELE_READ)
epe.events |= EPOLLIN;
if (e->write_cb != NULL)
if (e->events & ELE_WRITE)
epe.events |= EPOLLOUT;
if (epoll_ctl(eloop->fd, EPOLL_CTL_ADD, e->fd, &epe) == -1)
return -1;

View File

@ -179,7 +179,7 @@ ps_root_mreaderror(struct dhcpcd_ctx *ctx, void **data, size_t *len)
.psr_ctx = ctx,
};
if (eloop_event_add(ctx->ps_eloop, ctx->ps_root_fd,
if (eloop_event_add(ctx->ps_eloop, ctx->ps_root_fd, ELE_READ,
ps_root_mreaderrorcb, &psr_ctx) == -1)
return -1;