EPOLL: Why not set EPOLLONESHOT in add_interest when ONESHOT is set?
KiventD opened this issue · comments
In https://github.com/alibaba/PhotonLibOS/blob/main/io/epoll.cpp#L144, there is comment that "since epoll oneshot shows totally different meanning of ONESHOT in photon all epoll action keeps no oneshot".
I do not understand what it means. Can anything go wrong if setting EPOLLONESHOT
to underlying epoll_ctl's flags when ONESHOT
is set in photon?
EPOLLONESHOT only disable the event interest of the fd, leaving the registration inside the epoll's in-kernel data structure after an event.
Whereas photon's one-shot is stateless, leaving nothing in the engine after an event. So we delete the registration from epoll right after an event, which makes EPOLLONESHOT useless.
I made a study to find out that, closing an fd will silently remove possible registration from epoll:
https://stackoverflow.com/questions/43034535/do-i-get-a-notification-from-epoll-when-a-fd-is-closed
So, the potential leakage of using EPOLLONESHOT in photon is perhaps acceptable.