On Mon, Jan 31, 2011 at 12:42 PM, Marco <[email protected]> wrote: > Hi everyone, simple question.. > > 2 threads, T1 is in the event loop, T2 does some other things. > Assume that I have a safe way of communicating between T1 and T2. > > I'm planning to use T2 to create http requests objects and then give them to > T1 to actually perform the request, i.e.: > > T2 calls > - evhttp_connection_base_new > - evhttp_connection_set_timeout > - evhttp_connection_set_retries > - evhttp_connection_set_closecb > - evhttp_request_new > > Then T2 passes the evhttp_connection and evhttp_request to T1, who calls > evhttp_make_request. > (again, assume this message passing is implemeted safely) > > Is this thread safe? > Or does any of the functions invoked by T2 modify the event base (owned by > T1)?
Hm. All I can go with in response here is that "evhttp is not threadsafe"; nobody has done the sufficient thread-safety analysis on it. From what I can see, evhttp_connection_base_new makes a non-threadsafe bufferevent, which will indeed add and remove events from the event base. bufferevent_set_timeout, called by evhttp_conection_set_timeout, also manipulates events. I think you *might* be okay here, but I really can't guarantee it unless somebody takes a good hard look at the evhttp code in question. -- Nick *********************************************************************** To unsubscribe, send an e-mail to [email protected] with unsubscribe libevent-users in the body.
