2006-01-13 13:38:48

by Howard Chu

[permalink] [raw]
Subject: epoll_wait, epoll_ctl

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?

--
-- 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/


2006-01-13 16:12:12

by Davide Libenzi

[permalink] [raw]
Subject: Re: epoll_wait, epoll_ctl

On Fri, 13 Jan 2006, Howard Chu wrote:

> 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


2006-01-13 22:52:16

by David Schwartz

[permalink] [raw]
Subject: RE: epoll_wait, epoll_ctl


> 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.

> 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