[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [Libevent-users] multithreading problem
On Sun, Dec 16, 2012 at 10:52 AM, Björn K. <bjoernk2@xxxxxxxxxxxxxx> wrote:
> Hello,
>
> I'm trying to write a simple https server which utilizes multiple cpu cores.
> I call evthread_use_pthreads() and create several pthreads
I can't tell without looking at the rest of the program, but are you
sharing one event_base among all these threads? You can't run
event_base_loop or event_base_dispatch on the same event_base from
more than one thread at once.
To do what you want, you could either have one event_base per thread,
and some mechanism to assign each incoming connection gets assigned to
a separate event_base, or you could have one event_base, and use
worker threads to do the work of actually parsing HTTP and answering
HTTP requests.
For an example of an existing library that does what you want
(multithreaded high-performance HTTP with SSL in Libevent), see Mark
Ellzey's libevhtp at https://github.com/ellzey/libevhtp .
yrs,
--
Nick
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users in the body.