What is the order in which file descriptors are returned in epoll?

Let's say I installed a set of file descriptors, for example 8, 9, 10, 11, 12 in that order, and do epoll_wait () to read the data on them.

epoll_wait returns the data that should be read on sockets 8,10 and 11. Will there be an order of the file descriptors returned in the epoll array, 8, 10 and 11, or could they be mixed up?

+4
source share
2 answers

The manual page does not say anything specific about ordering, so it would probably be nice to depend on the order when you name it. Even if they were returned in order in one implementation, they may not be in another. It would be better to assume that they can be returned in any order.

+3
source

Think about it logically. Presumably, they are not all marked as readable as a single atomic operation, and epoll_wait can then simply return only 1 fd each time it is called. It makes no sense to depend on the order of its output.

0
source

Source: https://habr.com/ru/post/1402226/


All Articles