Skip to content

Commit

Permalink
Merge pull request mongrel2#106 from carlopires/fix-ssl-send
Browse files Browse the repository at this point in the history
Fix ssl_send to send data in chunks of SSL_MAX_CONTENT_LEN
  • Loading branch information
zedshaw committed Feb 14, 2012
2 parents b6d24f8 + a1efe95 commit 88f9b96
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,20 @@ static int ssl_do_handshake(IOBuf *iob)

static ssize_t ssl_send(IOBuf *iob, char *buffer, int len)
{
ssize_t sent = 0;

check(iob->use_ssl, "IOBuf not set up to use ssl");
if(!iob->handshake_performed) {
int rcode = ssl_do_handshake(iob);
check(rcode == 0, "handshake failed");
}
return ssl_write(&iob->ssl, (const unsigned char*) buffer, len);

do {
// must send in chunks of SSL_MAX_CONTENT_LEN
sent += ssl_write(&iob->ssl, (const unsigned char*) (buffer + sent), (len - sent));
} while (sent < len);

return sent;
error:
return -1;
}
Expand Down

0 comments on commit 88f9b96

Please sign in to comment.