Unverified Commit 0b645d63 authored by Yossi Gottlieb's avatar Yossi Gottlieb Committed by GitHub
Browse files

Fix TLS issues with large replies (#10909)

This problem was introduced by 496375fc and seems to more easily reproduce on macOS since OpenSSL writes more frequently return with EAGAIN.
parent 69d55768
...@@ -834,12 +834,12 @@ static int connTLSWritev(connection *conn_, const struct iovec *iov, int iovcnt) ...@@ -834,12 +834,12 @@ static int connTLSWritev(connection *conn_, const struct iovec *iov, int iovcnt)
* which is not worth doing so much memory copying to reduce system calls, * which is not worth doing so much memory copying to reduce system calls,
* therefore, invoke connTLSWrite() multiple times to avoid memory copies. */ * therefore, invoke connTLSWrite() multiple times to avoid memory copies. */
if (iov_bytes_len > NET_MAX_WRITES_PER_EVENT) { if (iov_bytes_len > NET_MAX_WRITES_PER_EVENT) {
size_t tot_sent = 0; ssize_t tot_sent = 0;
for (int i = 0; i < iovcnt; i++) { for (int i = 0; i < iovcnt; i++) {
size_t sent = connTLSWrite(conn_, iov[i].iov_base, iov[i].iov_len); ssize_t sent = connTLSWrite(conn_, iov[i].iov_base, iov[i].iov_len);
if (sent <= 0) return tot_sent > 0 ? tot_sent : sent; if (sent <= 0) return tot_sent > 0 ? tot_sent : sent;
tot_sent += sent; tot_sent += sent;
if (sent != iov[i].iov_len) break; if ((size_t) sent != iov[i].iov_len) break;
} }
return tot_sent; return tot_sent;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment