On Wednesday 09 July 2008 16:59, Alexander Drozdov wrote: > I have 2 processes in my program, both use libevent. > > I want to call event_base_free() in the child process to free parent's > event_base before the next event_init() call. But this doesn't work > correctly when using epoll because listening events of epolling descriptors > are shared.
Calling event_base_free() in the child process is no good for kqueue as well, because kqueue fd is not inherited after fork, so kq_del() will operate on invalid fd. I also want this issue to be resolved, by the way. My approach is to have special function (independent from event method) to recover child process after fork which does not require you to remove events from event device and then call event_base_free(). Instead all resources allocated for libevent "base" are just freed in one go: void event_base_close(struct event_base *base) { int i; if (base == NULL && current_base) base = current_base; if (base == current_base) current_base = NULL; assert(base); if (base->evsel->dealloc != NULL) base->evsel->dealloc(base, base->evbase); min_heap_dtor(&base->timeheap); for (i = 0; i < base->nactivequeues; ++i) event_free(base->activequeues[i]); event_free(base->activequeues); event_free(base); } > > See my fix (hack?) for this. > > Note that there is another bug in event_base_free() registered in > libevent's bug tracking system (2012318): > > https://sourceforge.net/tracker/index.php?func=detail&aid=2012318&group_id= >50884&atid=461322 > > Alexander Drozdov -- 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 _______________________________________________ Libevent-users mailing list Libevent-users@monkey.org http://monkeymail.org/mailman/listinfo/libevent-users