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

Re: [Libevent-users] Crash in my simple multi-threaded evhttp app [code incl.]



On Thu, Jun 28, 2012 at 7:38 AM, Julian Bui <julianbui@xxxxxxxxx> wrote:
Thanks for replying, Nick.

I probably cannot use libevhtp because it appears to be too small of a project to get company approval for my application.  We worry about support and maintenance issues.

Does anyone have any other suggestions for an embedded http server/library that has multi-threaded support?  

I've been programming with libevent for a few weeks now and have really liked the interfaces and capabilities which makes it frustrating to hear that I won't be able to use the http capabilities because of its threading limitations.  

You should be able to use libevent http in multithreaded application, but you must access libevent http code only from libevent thread.

This means that you will have to read requests in the libevent thread and put them in a queue for processing by the other thread. When processing is done, put the requests in a new queue, which libevent thread will process, and wake up the libevent thread.

You will have to add a pipe or socket for waking up libevent thread, and and in the read callback you will drain the queue of processed requests.