Skip to content

Commit

Permalink
Change bufferevent_openssl::do_write so it doesn't call SSL_write wit…
Browse files Browse the repository at this point in the history
…h 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.
  • Loading branch information
Mike Smellie authored and nmathewson committed Jul 19, 2010
1 parent 7c92691 commit c991317
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions bufferevent_openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit c991317

Please sign in to comment.