[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [Libevent-users] Problems with outbound HTTP posts





On Wed, Oct 24, 2012 at 6:09 PM, Ringel, Rick <Rick.Ringel@xxxxxxxx> wrote:

Thanks for taking a look.

 

| Did you initialize libevent threading?

|

| See http://www.wangafu.net/~nickm/libevent-book/Ref1_libsetup.html Section "Locks and threading"

 

I just reviewed that page, and I am calling the ‘evthread_use_pthreads()’ to initialize.  I did add ‘evthread_enable_lock_debuging()’, but that didn’t produce any new information.


evhttp cannot be used from multiple threads. If you want to post messages from other threads, you should use message queues between the libevent http thread and the other threads.

To pass a message to evhttp thread, add the message to the queue, and use event_activate() to wake up the event loop. In the event callback, pop messages from the queue and handle them (e.g. send http post request).

You don't need the while loop around event_base_dispatch - it is your loop.