Fix TLS issues with large replies (#10909)

This problem was introduced by 496375f and seems to more easily reproduce on macOS since OpenSSL writes more frequently return with EAGAIN.
This commit is contained in:
Yossi Gottlieb 2022-07-03 13:35:58 +03:00 committed by GitHub
parent 69d5576832
commit 0b645d6319
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;
} }