OS-5882: epoll fails to wake on certain edge-triggered conditions


Issue Type:Bug
Priority:4 - Normal
Created at:2017-01-03T21:02:40.000Z
Updated at:2019-01-10T01:22:13.059Z


Created by:Former user
Reported by:Former user
Assigned to:Former user


Fixed: A fix for this issue is checked into the tree and tested.
(Resolution Date: 2017-02-14T02:53:42.000Z)

Fix Versions

2017-02-16 JAMAICA DECOY (Release Date: 2017-02-16)

Related Issues


There are certain circumstances under which epoll will fail to wake and emit events for descriptors under edge-triggered polling.

This small test program completes successfully on Linux but hangs on SmartOS:

#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
#include <sys/eventfd.h>
#include <sys/epoll.h>

int evfd = -1;

void *writer(void *args) {
        uint64_t val = 1;

        write(evfd, &val, sizeof (val));
    return NULL;

int main() {
        pthread_t thread_write;
        struct epoll_event epev;
        int epfd;

        evfd = eventfd(0, EFD_CLOEXEC|EFD_NONBLOCK);
        epfd = epoll_create1(0);

        epev.events = EPOLLIN|EPOLLOUT|EPOLLET;
        epev.data.fd = evfd;
        epoll_ctl(epfd, EPOLL_CTL_ADD, evfd, &epev);

        /* The eventfd is writable */
        epoll_wait(epfd, &epev, 1, -1);

        pthread_create(&thread_write, NULL, writer, NULL);

        /* The eventfd should report as readable once the above write succeeds */
        epoll_wait(epfd, &epev, 1, -1);

        pthread_join(thread_write, NULL);

One could argue that the same edge-triggered behavior in /dev/poll is also incorrect. Given the lack of proper specification, it's unclear.


Comment by Former user
Created at 2017-02-13T22:25:27.000Z

illumos-joyent commit 278a073 (branch master, by Patrick Mooney)

OS-5882 epoll fails to wake on certain edge-triggered conditions
OS-5884 epoll should not emit POLLNVAL
OS-5894 recursive epoll should emit EPOLLRDNORM
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Approved by: Robert Mustacchi <rm@joyent.com>

Comment by Jira Bot
Created at 2019-01-10T01:22:13.059Z

illumos-joyent commit f9b7abc6be240f4777d99c3a6bfa47119887b890 (branch master, by Patrick Mooney)

OS-7107 EPOLLONESHOT should not remove fd
OS-7479 Fix for OS-5882 checks wrong place for POLLET
Reviewed by: Bryan Cantrill <bryan@joyent.com>
Reviewed by: Mike Zeller <mike.zeller@joyent.com>
Approved by: Jerry Jelinek <jerry.jelinek@joyent.com>