]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Fix prior for epoll.
authorRoy Marples <roy@marples.name>
Tue, 2 Feb 2021 15:10:20 +0000 (15:10 +0000)
committerRoy Marples <roy@marples.name>
Tue, 2 Feb 2021 15:10:20 +0000 (15:10 +0000)
src/dev.c
src/eloop.c
src/privsep-root.c

index d33c8faaa230de2a5548d09da3c9962e5ff03d9b..88dfc0dee23b50ca755f482c082f7a14936d7edf 100644 (file)
--- a/src/dev.c
+++ b/src/dev.c
@@ -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__);
index ab8d289cfac7f9907dab05e6c7c1cabaa80b09ae..32042c5447e27fe79edc1fecea642efe121ab863 100644 (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;
index 03f682661a91cd12a5ea63bd3293769f5852e64d..b09a67daa38e35a172e723f92014ca7e6c0d1cce 100644 (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;