Skip to contentSkip to conversation

epoll_wait, epoll_ctl

DISCUSSION Howard Chu 3 participants 3 messages Jan 13, 2006

lore
Share & tools
lore

Howard Chu

author
#0 lore raw

So, what's supposed to happen in a threaded program where one thread does an epoll_ctl on an epoll fd while another thread is currently waiting in epoll_wait on the same fd? In particular, what happens if a thread does an EPOLL_CTL_DEL on one of the fds that is currently being waited on? Is there a possibility of an event being returned on the fd even after the EPOLL_CTL_DEL completes?

Signature · 4 lines
 -- Howard Chu
 Chief Architect, Symas Corp.  http://www.symas.com
 Director, Highland Sun        http://highlandsun.com/hyc
 OpenLDAP Core Team            http://www.openldap.org/project/
#1 lore raw
Quoted 1 line · Howard Chu

So, what's supposed to happen in a threaded program where one thread does an epoll_ctl on an epoll fd while another thread is currently waiting in epoll_wait on the same fd? In particular, what happens if a thread does an EPOLL_CTL_DEL on one of the fds that is currently being waited on? Is there a possibility of an event being returned on the fd even after the EPOLL_CTL_DEL completes?

The same thing that happens when you close a file on another thread, nothing (besides the file being automatically removed from the set). Removing a file (either by close or by EPOLL_CTL_DEL) is not an event.

- Davide

#2 lore raw
In reply to Howard Chu
Quoted 4 lines

So, what's supposed to happen in a threaded program where one thread does an epoll_ctl on an epoll fd while another thread is currently waiting in epoll_wait on the same fd?

Nothing special.

Quoted 4 lines

In particular, what happens if a
thread does an EPOLL_CTL_DEL on one of the fds that is currently being waited on? Is there a possibility of an event being returned on the fd even after the EPOLL_CTL_DEL completes?

Absolutely. The EPOLL_CTL_DEL might not even start until after the event
has been determined to be returned and the wait is in the process of returning.

DS