So i'm using libevent thus far to handle incoming requests and new
connections. When new connections come in or data on an already connected
socket come in, i'd like to pass off the connection to a thread to let the
thread handle the data transactions and processing. I'm doing this by
putting a socket id on a ring buffer and having the worker threads pull from
the ring buffer as new tasks become available. The problem with this (or so
it seems to me) is that I can't add the event back to the event handler
until the worker thread has finished reading all the available data from the
socket or else libevent will keep signaling that there is data waiting to be
read and flood my ring buffer with requests. If it isn't apparent already, I
can't add the event in the worker threads because libevent (as i understand
it) isn't thread safe like that. So how do I go about implementing a system
that will allow worker threads to handle a connection and have a master
libevent thread handle events? Additionally, I'd like to also be able to
have the worker threads somehow close the connection in the instance that
the client gets disconnected between the time the client sends in a request
and the time that the worker picks up the request and processes it. Thanks
in advance for any help.

Oh, additionally, It seems like once an event handler gets an event, I don't
need to event_del() the event since its already removed from the event stack
but i just wanted to clarify that if someone could answer this question for
me. Thanks
_______________________________________________
Libevent-users mailing list
[EMAIL PROTECTED]
http://monkey.org/mailman/listinfo/libevent-users

Reply via email to