Page MenuHomeFreeBSD

Linux epoll: Allow passing of any negative timeout value to epoll_wait
ClosedPublic

Authored by wulf on Nov 23 2019, 12:19 PM.

Details

Summary

Linux epoll allow passing of any negative timeout value to epoll_wait
to cause unbound blocking

This fixes (test5(-2)) failure of epoll-shim test suite: https://github.com/jiixyj/epoll-shim

Test Plan
/* Sample testcase */

#include <sys/epoll.h>
#include <assert.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int
main(int argc, char *argv[])
{
        struct epoll_event event, events[1];
        int epfd, err;

        epfd = epoll_create1(EPOLL_CLOEXEC);
        assert(epfd);

        event.events = EPOLLOUT;
        err = epoll_ctl(epfd, EPOLL_CTL_ADD, STDOUT_FILENO, &event);
        assert(err == 0);

        if (epoll_wait(epfd, events, 1, -2) <= 0) {
                perror("epoll_wait failed");
                exit(EXIT_FAILURE);
        }

        printf("ok\n");
        return (EXIT_SUCCESS);
}

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

emaste added a subscriber: emaste.
emaste added inline comments.
sys/compat/linux/linux_event.c
584 ↗(On Diff #64759)

Note that the man page states Specifying a timeout of -1 causes epoll_wait() to block indefinitely so please add a comment here mentioning the difference between what Linux documents and actually implements.

This revision is now accepted and ready to land.Nov 23 2019, 4:13 PM