Can epoll_wait() > 1 with only 1 socket and 1 event -- EPOLLIN?

673 views Asked by At

Let's say I epoll_create1() and only interest in EPOLLIN | EPOLLET for 1 socket.

Is it possible that I will get epoll_wait() > 1 (assuming timeout=-1) for that socket and the event is EPOLLIN?

Or will epoll_wait() return 1 even there are multiple packets (let's say spread over few sec that I pause the program on purpose in the epoll_wait loop)?

Thanks in advance.

2

There are 2 answers

2
Kerrek SB On BEST ANSWER

epoll_wait returns the number of events, which according to the documentation equals the "number of file descriptors ready for I/O". So you cannot get more events than the number of file descriptors you have registered.

1
Mats Petersson On

According to these docs for epoll_wait it should return the number of fd's that are "ready". If you only pass in one fd, then you should not get more than 1 back - that would certainly be a bug in the epoll_wait implementation, and it's been around for a while, so I expect it's fairly well tested (unless you are working on a completely new architecture or a beta-version of a C library or some such).

Also, timeout = 0, not -1.