Bug 24132

Summary: EPOLLERR event is lost when epoll descriptor is polled
Product: IO/Storage Reporter: Jaroslav Šmíd (jardasmid)
Component: OtherAssignee: io_other
Status: RESOLVED DOCUMENTED    
Severity: normal CC: alan, harryjackson
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 2.6.36.1 Subsystem:
Regression: No Bisected commit-id:
Attachments: C code example

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.