Make sure we send with the same arguments again if SSL_write() fails with SSL_ERROR_WANT_READ.

This commit is contained in:
Jan Vidar Krey 2009-08-03 19:54:28 +02:00
parent 22f9be95d0
commit 7229ad68ab

View File

@ -221,15 +221,20 @@ ssize_t net_con_send(struct net_connection* con, const void* buf, size_t len)
} }
else else
{ {
if (net_con_flag_get(con, NET_WANT_SSL_READ) && con->write_len)
len = con->write_len;
int ret = SSL_write(con->ssl, buf, len); int ret = SSL_write(con->ssl, buf, len);
LOG_DEBUG("net_send: ret=%d", ret); LOG_DEBUG("net_send: ret=%d", ret);
if (ret > 0) if (ret > 0)
{ {
con->last_send = time(0); con->last_send = time(0);
net_con_flag_unset(con, NET_WANT_SSL_READ); net_con_flag_unset(con, NET_WANT_SSL_READ);
con->write_len = 0;
} }
else else
{ {
con->write_len = len;
return handle_openssl_error(con, ret); return handle_openssl_error(con, ret);
} }
return ret; return ret;