[Libevent-users] bug in event_base_free()
Andrei Nigmatulin
anight at eyelinkmedia.com
Tue Jun 12 19:33:27 EDT 2007
Hello, list
Please consider my application:
1. There is one process that always in event loop (master process).
2. By some event it forks and create "child" process, that call
event_exit_loop() and after event_loop() exits it try to clean up everything
associated with libevent.
3. For this purpose child call event_base_free(), but it have to remove all
events that was added by parent before fork happened. Otherwise it will be
hit by assert(TAILQ_EMPTY(&base->eventqueue)).
4. With poll or select methods there no problems with deleting events at this
point.
5. But with epoll, kqueue or event ports methods the child and the parent
shares *same* event device and set of file descriptors after fork(). So if
child call event_del() on every event that was added before in parent, events
are also deleted from parent's device (actually, the same device), which is
absolutely not what I want.
Thus, there is only one way to deal with it: child must not call
event_base_free() and must live with opened event device.
Attached diff provides a fix for this situation. I believe process must not
check if base->eventqueue and other queues are empty. Calling
evsel->dealloc() is enough to remove all events.
--
Andrei Nigmatulin
GPG PUB KEY 6449830D
Now I lay me down to sleep(3)
Pray the OS my core to keep
If I die before I wake
Pray the Disk my core to take
-------------- next part --------------
A non-text attachment was scrubbed...
Name: libevent-base_free.diff
Type: text/x-diff
Size: 632 bytes
Desc: not available
Url : http://monkeymail.org/archives/libevent-users/attachments/20070613/403e0612/libevent-base_free.bin
More information about the Libevent-users
mailing list