[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Fwd: [Libevent-users] Using libevent in multi-threaded server
- To: libevent-users@xxxxxxxxxxxxx
- Subject: Fwd: [Libevent-users] Using libevent in multi-threaded server
- From: Azat Khuzhin <a3at.mail@xxxxxxxxx>
- Date: Fri, 8 Dec 2017 12:40:03 +0300
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: libevent-users-outgoing@xxxxxxxx
- Delivered-to: libevent-users@xxxxxxxx
- Delivery-date: Fri, 08 Dec 2017 04:40:07 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=1b6iYGObGWaPkn8EbpKTuuN54JygLYWRE/WpKFkLN+U=; b=YnHMhuyzAUSmzLSGDmSSyhBqSl3bm8GtuNkJQnqp7dm0RFxnlv5Odxd6Fasi0mY6Ln qzdLFq7gPBjP5zprYMy89H6nu2+ICE0lhjltXRhx6zn8avJtnf7Kv2C+En7fX32CrylI 6/gv/y4l5TsV0fYXjYRTPUtSw2osuDQ0ifMfD+V8QqwnBLbV9+M9Kel9qXxqbrlGsCa0 U8QnRszUcdVYVP3VYDTsx/nWcwzr99jWvVsGTIT4/EVt+jUiwsMoISIuE8Wz+FeJsTAd 4LUQatKyhNgvVnEQCcl7vER9YWgEk/QHT5Sw9qARH3IMFnpLL5q38iWDhKMfleeyVEWs JC6Q==
- In-reply-to: <CAG5DWoh_eyf_hjstkvjqJ-Qi93v4VG=Jy2d+5gPhTqx2GNv4XA@mail.gmail.com>
- References: <3ed17f12-95a6-f5ed-fbb1-2f1f76bcd6a3@foxt.com> <CAG5DWoh_eyf_hjstkvjqJ-Qi93v4VG=Jy2d+5gPhTqx2GNv4XA@mail.gmail.com>
- Reply-to: libevent-users@xxxxxxxxxxxxx
- Sender: owner-libevent-users@xxxxxxxxxxxxx
On Thu, Dec 7, 2017 at 4:38 PM, Leif Thuresson <leif.thuresson@xxxxxxxx> wrote:
> Hi,
> Seeking advice from experienced libevent users.
>
> I'm working on a server doing SSL socket I/O and I want to hand off the
> CPU hungry SSL read/write to threads in a threadpool to gain performance.
> I want to have read events pending all the time but write events only
> when there is something in queue for output.
> To be able to switch read and write events on/off independently I think the
> standard solution
> is to create two separate event object for each file descriptor.
> In the server one thread is running the event-loop and the event callback
> hand off the
> execution of a secondary application I/O callbacks to a thread in the
> threadpool that
> performs the actual I/O.
> A problem with using two separate event objects is that I risk getting both
> a read and
> a write application callback running at the same time in different threads
> which will crash the SSL I/O.
Hi,
So you have a thread pool, and hence you can just add event_base per
thread in this pool, and so when you server accept the fd, you just
pass it to the event_base of that thread and that's it. Because in
this case EV_READ/EV_WRITE cannot be run in parallel. And I think that
this is the most optimal choice.
Also didn't you looked at bufferevent_openssl_socket_new(), maybe this
could simplify your code.
Azat.
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users in the body.