What is the order in which File Descriptors in epoll are returned?

旧时模样 提交于 2019-12-01 17:05:28

问题


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

epoll_wait returns with data to be read on socket 8,10 and 11. Will the order of the file descriptors returned in the epoll array be 8, 10 and 11 or could they be jumbled?


回答1:


The man page does not say anything specifically about the order, so it probably would not be a good idea to depend on the order when you call it. Even if they were returned in order in one implementation, they might not be in another. It would be best to assume that they could be returned in any order.




回答2:


Just think about it logically. Presumably they're not all marked as readable as a single atomic operation, and epoll_wait might then just as well just return 1 fd available each time it's called. It makes no sense to depend on the order of it's output.



来源:https://stackoverflow.com/questions/9770368/what-is-the-order-in-which-file-descriptors-in-epoll-are-returned

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!