Hello,

I'm getting very strange behaviour from libevent (when using it with
epoll()). My program (BitlBee in ForkDaemon mode) has a master process
which accepts clients and creates a new child process for every
connection. When using select() or poll() for event handling, this works
perfectly. However, when using epoll() (which is the whole reason I
started using libevent, GLib can do event handling with poll()/select()
already) things go wrong once there's more than one client.

With only one client everything works perfectly, but once there's
another one, process 1 seems to get the other process' event
notifications. (Process 2 does get the notifications too, BTW.) Process
1 then tries to read from the socket, gets EAGAIN and panics because it
obviously doesn't expect to get such an error in a "there's data, read
it" event handler.

Most likely this behaviour comes from the fact that all processes share
one epoll fd, which is hardly ever a good idea. See this post:

http://www.ussg.iu.edu/hypermail/linux/kernel/0403.0/0300.html

So now I'm wondering, how do I make sure every process gets its own
epfd? I found epoll_base_free(), but it's probably not what I'm looking
for, because of this line:

assert(TAILQ_EMPTY(&base->eventqueue));

This means that I have to remove all event handlers to make this
function call successful, right? I really shouldn't do that, because
most likely doing that will remove the event handler in the parent
process too!!! (See the rest of the thread above.)

So, does anybody know what to do to make this work properly?


Wilmer van der Gaast.

-- 
+-------- .''`.     - -- ---+  +        - -- --- ---- ----- ------+
| wilmer : :'  :  gaast.net |  | OSS Programmer   www.bitlbee.org |
| lintux `. `~'  debian.org |  | Full-time geek  wilmer.gaast.net |
+--- -- -  ` ---------------+  +------ ----- ---- --- -- -        +



Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Libevent-users mailing list
Libevent-users@monkey.org
http://monkey.org/mailman/listinfo/libevent-users

Reply via email to