Change bufferevent_openssl::do_write so it doesn't call SSL_write with a 0 length buffer

I was running into a problem when using bufferevent_openssl with a
very simple echo server.  My server simply bufferevent_read_buffer 'd
data into an evbuffer and then passed that evbuffer straight to
bufferevent_write_buffer.

The problem was every now and again the write would fail for no
apparent reason. I tracked it down to SSL_write being called with the
amount of data to send being 0.

This patch alters do_write in bufferevent_openssl so that it skips
io_vecs with 0 length.
This commit is contained in:
Mike Smellie 2010-07-19 15:31:19 +12:00 committed by Nick Mathewson
parent 7c926916b2
commit c991317409

View File

@ -617,6 +617,12 @@ do_write(struct bufferevent_openssl *bev_ssl, int atmost)
if (bev_ssl->bev.write_suspended)
break;
/* SSL_write will (reasonably) return 0 if we tell it to
send 0 data. Skip this case so we don't interpret the
result as an error */
if (space[i].iov_len == 0)
continue;
r = SSL_write(bev_ssl->ssl, space[i].iov_base,
space[i].iov_len);
if (r > 0) {