Re: [Libevent-users] Re: Avoid potential SSL read spinlocks

2011-11-16 Thread Catalin Patulea
On Wed, Nov 16, 2011 at 11:52 AM, Catalin Patulea wrote: > - Peer sends two (small) SSL records in a row (perhaps in the same TCP > segment) > - fd becomes readable, libevent delivers read_cb to bev_ssl > - bev_ssl calls SSL_read only once - does this read process only the > first record or both?

Re: [Libevent-users] Re: Avoid potential SSL read spinlocks

2011-11-16 Thread Catalin Patulea
A few things I forgot to mention: Re: bev_ssl needing deferred or not, without OPT_DEFER_CALLBACKS, https-client does not work for me. I haven't investigated. Re: SSL_read loops. Consider the following scenario: - Peer sends two (small) SSL records in a row (perhaps in the same TCP segment) - fd

Re: [Libevent-users] Re: Avoid potential SSL read spinlocks

2011-11-16 Thread Catalin Patulea
On Tue, Nov 15, 2011 at 10:25 AM, Mark Ellzey wrote: > Also, would be nice to have some code that reproduces the issue you are > having. Ok, try the attached patch against 9ae6e595 (just before your fixes). The use of an IP in the URL is incidental because of IPv6 issues on my system - you can pro

Re: [Libevent-users] Re: Avoid potential SSL read spinlocks

2011-11-15 Thread Mark Ellzey
On Tue, Nov 15, 2011 at 10:48:10AM -0600, Mark Ellzey wrote: > On Mon, Nov 14, 2011 at 07:21:00PM -0600, Mark Ellzey wrote: > > On Mon, Nov 14, 2011 at 07:13:39PM -0600, Mark Ellzey wrote: > > > > > > We cannot schedule or call the readcb UNTIL SSL_read() returns > 0 OR an > > > error occurs on th

Re: [Libevent-users] Re: Avoid potential SSL read spinlocks

2011-11-15 Thread Mark Ellzey
On Mon, Nov 14, 2011 at 07:21:00PM -0600, Mark Ellzey wrote: > On Mon, Nov 14, 2011 at 07:13:39PM -0600, Mark Ellzey wrote: > > > > We cannot schedule or call the readcb UNTIL SSL_read() returns > 0 OR an > > error occurs on the socket. > > I definitely feel confident this is the issue, going int

Re: [Libevent-users] Re: Avoid potential SSL read spinlocks

2011-11-14 Thread Mark Ellzey
On Mon, Nov 14, 2011 at 07:13:39PM -0600, Mark Ellzey wrote: > > We cannot schedule or call the readcb UNTIL SSL_read() returns > 0 OR an > error occurs on the socket. I definitely feel confident this is the issue, going into that loop provided ample time for SSL_read() to process an entire recor

Re: [Libevent-users] Re: Avoid potential SSL read spinlocks

2011-11-14 Thread Mark Ellzey
On Mon, Nov 14, 2011 at 02:30:32PM -0800, Catalin Patulea wrote: > This is actually causing an assert in my case :( The key is to get > SSL_read to return both data (> 0) and EOF (= 0) within the same > iteration of that (former) while loop. Then the flow looks like this: > > SSL_read() returns N

Re: [Libevent-users] Re: Avoid potential SSL read spinlocks

2011-11-14 Thread Catalin Patulea
On Mon, Nov 14, 2011 at 11:17 AM, Mark Ellzey wrote: > As far as I know, it doesn't. But I wrote this patch because if you are > using a deferred bev with bulk incoming data, it never drops back into > base_loop() until SSL_read() says there is nothing to read. This is due > to the fact that your

Re: [Libevent-users] Re: Avoid potential SSL read spinlocks

2011-11-14 Thread Mark Ellzey
On Mon, Nov 14, 2011 at 11:03:58AM -0800, Catalin Patulea wrote: > Hi, > > Why does bev_ssl require deferred callbacks? > As far as I know, it doesn't. But I wrote this patch because if you are using a deferred bev with bulk incoming data, it never drops back into base_loop() until SSL_read() sa

[Libevent-users] Re: Avoid potential SSL read spinlocks

2011-11-14 Thread Catalin Patulea
Hi, Why does bev_ssl require deferred callbacks? Commit fc52dbac (see below) fixed an issue I was seeing where deferred error_cb(EOF)s were confusing clients which had disabled EV_READs (notably evhttp). If bev_ssl didn't require deferred cbs, the EOFs would have stayed queued at the OpenSSL laye