On Mon, Apr 19, 2010 at 11:24 PM, Denis Bilenko <[email protected]> wrote: > Hi, > > I've run into an issue where event_add() fails with ENOENT. > This happens when a socket reuses a descriptor that was recently > closed and was used before with another event. > > The details are below. The question I have is - what are the ways to > work around this? >
You must never modify an event that is currently pending. If you want to reassign it, you need to call event_del(), then modify it, then call event_add(). For some backends (like epoll and kqueue) you need to call event_del() on the event when you close the socket, and then event_add() again, even if the fd didn't change: as far as the kernel is concerned, it is no longer interested in tracking fd, once the socket has closed. -- Nick *********************************************************************** To unsubscribe, send an e-mail to [email protected] with unsubscribe libevent-users in the body.
