[Libevent-users] Multiple identical events on same fd in same loop

2009-03-07 Thread Thor Lancelot Simon
I'm trying to cope with OpenSSL's braindamaged nonblocking API (my coworkers and I tend to call it the "accidental programming interface") in a libevent application. The application handles a bidirectional data stream and, for simplicity's sake, maintains a small static buffer in each direction, c

Re: [Libevent-users] Multiple identical events on same fd in same loop

2009-03-08 Thread Nick Mathewson
On Sat, Mar 07, 2009 at 01:45:21PM -0500, Thor Lancelot Simon wrote: [...] > I see two ways to handle this. One is with very, very nasty application > logic, and the other is to simply set two separate events with the SSL > fd, each waiting on EV_WRITE. So when the SSL fd comes ready for write -

Re: [Libevent-users] Multiple identical events on same fd in same loop

2009-03-20 Thread Thor Lancelot Simon
On Sun, Mar 08, 2009 at 07:28:58PM -0400, Nick Mathewson wrote: > On Sat, Mar 07, 2009 at 01:45:21PM -0500, Thor Lancelot Simon wrote: > [...] > > I see two ways to handle this. One is with very, very nasty application > > logic, and the other is to simply set two separate events with the SSL > >

Re: [Libevent-users] Multiple identical events on same fd in same loop

2009-03-20 Thread Dan Kegel
On Fri, Mar 20, 2009 at 7:45 AM, Thor Lancelot Simon wrote: >> The first way is what you have to do with Libevent 1.4.x and earlier; >> Libevent only supports one _pending_ event at a time per fd/operation >> pair.  In other words, it's okay to have two events set to watch >> EV_WRITE on the same

Re: [Libevent-users] Multiple identical events on same fd in same loop

2009-03-20 Thread Adrian Chadd
On Fri, Mar 20, 2009, Thor Lancelot Simon wrote: > > The first way is what you have to do with Libevent 1.4.x and earlier; > > Libevent only supports one _pending_ event at a time per fd/operation > > pair. In other words, it's okay to have two events set to watch > > EV_WRITE on the same FD, but

Re: [Libevent-users] Multiple identical events on same fd in same loop

2009-03-20 Thread Adrian Chadd
On Fri, Mar 20, 2009, Dan Kegel wrote: > > Just to clarify: I can add two events, one for EV_READ and one for > > EV_WRITE, on the same FD, with different callbacks, and that _will_ > > work as expected? > > Even if that works, isn't it inefficient at the syscall level somehow? It can be. For th

Re: [Libevent-users] Multiple identical events on same fd in same loop

2009-03-20 Thread Thor Lancelot Simon
On Fri, Mar 20, 2009 at 07:46:51AM -0700, Dan Kegel wrote: > On Fri, Mar 20, 2009 at 7:45 AM, Thor Lancelot Simon wrote: > >> The first way is what you have to do with Libevent 1.4.x and earlier; > >> Libevent only supports one _pending_ event at a time per fd/operation > >> pair. ?In other words,

Re: [Libevent-users] Multiple identical events on same fd in same loop

2009-03-20 Thread Dan Kegel
On Fri, Mar 20, 2009 at 8:06 AM, Thor Lancelot Simon wrote: >> > Just to clarify: I can add two events, one for EV_READ and one for >> > EV_WRITE, on the same FD, with different callbacks, and that _will_ >> > work as expected? >> >> Even if that works, isn't it inefficient at the syscall level so

Re: [Libevent-users] Multiple identical events on same fd in same loop

2009-03-20 Thread Thor Lancelot Simon
On Fri, Mar 20, 2009 at 07:58:13AM -0700, Niels Provos wrote: > On Fri, Mar 20, 2009 at 7:45 AM, Thor Lancelot Simon wrote: > > Just to clarify: I can add two events, one for EV_READ and one for > > EV_WRITE, on the same FD, with different callbacks, and that _will_ > > work as expected? > > Yes,

Re: [Libevent-users] Multiple identical events on same fd in same loop

2009-03-20 Thread Thor Lancelot Simon
On Fri, Mar 20, 2009 at 08:13:05AM -0700, Dan Kegel wrote: > On Fri, Mar 20, 2009 at 8:06 AM, Thor Lancelot Simon wrote: > >> > Just to clarify: I can add two events, one for EV_READ and one for > >> > EV_WRITE, on the same FD, with different callbacks, and that _will_ > >> > work as expected? > >

Re: [Libevent-users] Multiple identical events on same fd in same loop

2009-03-20 Thread Adrian Chadd
On Fri, Mar 20, 2009, Thor Lancelot Simon wrote: > > Try doing it under strace and see what happens. > > I seem to recall it caused one epoll syscall per event > > on each time around the event loop. > > Ugh. That sounds like a terrible limitation of epoll. A syscall > _per event_? > > Once ag