Home Under what conditions will Linux epoll_wait return epoll_events struct with an empty events field?
Reply: 0

Under what conditions will Linux epoll_wait return epoll_events struct with an empty events field?

user9156 Published in September 21, 2018, 8:03 am

I've written an event loop to handle file descriptor read/write events. I have successfully written a version of the code that supports kqueue and a second version that supports select. I am working on my third and final version which will support epoll.

I am experiencing a problem when I register a new descriptor for a EPOLLIN event. The descriptor in question is already "listening" for connections, so I wait for a read event to occur so that I know the next call to "accept" will succeed (common practice for non-blocking accept).

All file descriptors are set to non-blocking.

My call to epoll_wait returns two events for the same descriptor. The first event has the event field set to the value of EPOLLIN. The second event structure has the event field set to 0 / empty. The data.fd field lists the same FD number as the first struct.

What are the circumstances where epoll_wait will return an event structure with a zeroed event field?

This does NOT happen every time but it happens 90+% of the time.

Lastly, I'd post code but this is written in Ruby and there is a LOT of boilerplate to wrap up the socket, listen, accept, etc. functions in FFI, set constants, etc. The example code would be quite long and unwieldy so I am not posting any code.

share|improve this question
  • 1
    What does this have to do with Ruby? Why is this better than using EventMachine? – tadman Feb 12 at 17:34
  • @tadman Your comment is off-topic. This is for the ruby-io project (search for it on github). I mention Ruby to explain why I can't post a short code snippet to repro the issue. – Chuck Remes Feb 12 at 18:02
  • You casually mention Ruby without posting code, sure, but you've also tagged this question Ruby which means there's something Ruby-related to it, which now you explain a little more about, but still not to a degree anyone can help you with. You're talking about epoll on Stack Overflow. Unless you have some code that's broken that you need help with this is probably too broad and off-topic. – tadman Feb 12 at 18:40

1 Answer 1

active oldest votes
up vote 0 down vote accepted
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.313645 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO