Bug 24132 - EPOLLERR event is lost when epoll descriptor is polled
Summary: EPOLLERR event is lost when epoll descriptor is polled
Status: RESOLVED DOCUMENTED
Alias: None
Product: IO/Storage
Classification: Unclassified
Component: Other (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: io_other
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-30 20:42 UTC by Jaroslav Šmíd
Modified: 2012-08-14 13:53 UTC (History)
2 users (show)

See Also:
Kernel Version: 2.6.36.1
Subsystem:
Regression: No
Bisected commit-id:


Attachments
C code example (1005 bytes, text/x-csrc)
2010-11-30 20:42 UTC, Jaroslav Šmíd
Details

Description Jaroslav Šmíd 2010-11-30 20:42:21 UTC
Created attachment 38642 [details]
C code example

I have two descriptors:
1) file descriptor for /proc/self/mountinfo opened for read (named mountinfofd)
2) epoll descriptor created with epoll_create() (named epollfd)

I add mountinfofd into epollfd using epoll_ctl, listening for event EPOLLERR.

When calling only epoll_wait() on the epollfd descriptor, I correctly get EPOLLERR event for mountinfofd everytime /proc/self/mountinfo file changes.

When I first poll() epollfd descriptor (for POLLIN event) to see if there are events in it, and file /proc/self/mountinfo changes, poll() returns correct event (POLLIN) for epollfd descriptor (meaning events are pending in epollfd). ... But if I call epoll_wait() after that, it returns no events, like if the event (EPOLLERR) got lost somehow.

See attached code for better understanding what I mean.
Comment 1 Harry 2012-01-18 06:42:48 UTC
I first thought this might be something to do with epoll only returning a single event when it's edge triggered but it looks like your epoll_wait is looking for an EPOLLERR that never happens and that's why it does not return anything. You get the POLLIN as expected but that's it. If you set your

e.events = EPOLLERR;

to 

e.events = EPOLLIN;

you get the event triggered.

Note You need to log in before you can comment on or make changes to this bug.