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.
Tags
None
Referenced Files
Unknown Object (File)
Dec 21 2023, 10:21 PM
Unknown Object (File)
Dec 20 2023, 5:13 AM
Unknown Object (File)
Nov 17 2023, 8:52 AM
Unknown Object (File)
Oct 24 2023, 7:12 AM
Unknown Object (File)
Aug 8 2023, 12:50 AM
Unknown Object (File)
Jun 26 2023, 7:16 PM
Unknown Object (File)
May 27 2023, 1:59 AM
Unknown Object (File)
May 14 2023, 6:42 PM
Subscribers

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 - subversion
Lint
Lint Not Applicable
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