[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [Libevent-users] Forked processes and signals



Nick Mathewson wrote:

Aha.  My testing was off, this makes more sense now.

The problem is indeed epoll-backend related.  The problem is that
after the fork, the subprocess shares the epoll fd with the parent
process, and these both refer to the same kernel epoll structure.
Ordinarily, you would call event_reinit() before using it, so that the
subprocess would now have its own separate structure.  But if you
instead call event_base_free() immediately, the subprocess calls
evsig_dealloc(), which calls event_del() on the ev_signal event, which
unregisters it from the shared epoll structure, so the master process
doesn't get signal events any more.

The workaround for now is to do event_reinit() *then*
event_base_free() in the subprocess.  I've tested it, and it seems to
work on Linux for me.
Thanks for the explanation and the workaround, I've just tested
it, it works perfectly.

The real fix is to make event_base_free() a bit smarter about the
epoll case.  This seems tricky; it probably wants to be a 2.1 fix,
since there is a workaround for 2.0.  I've opened a bug ticked so this
doesn't get forgotten: fixes are welcome!  (The ticket is at
https://sourceforge.net/tracker/?func=detail&aid=3202431&group_id=50884&atid=461322
)
Thanks! I can take a look at this if you want, but I must admit
that I don't know this part of the code yet.

Christophe


***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.