From 0b645d63193fb18a6646def558c37f6c7ee5d740 Mon Sep 17 00:00:00 2001 From: Yossi Gottlieb Date: Sun, 3 Jul 2022 13:35:58 +0300 Subject: [PATCH] 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. --- src/tls.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tls.c b/src/tls.c index 66c485ac28..e7787e63ab 100644 --- a/src/tls.c +++ b/src/tls.c @@ -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, * therefore, invoke connTLSWrite() multiple times to avoid memory copies. */ 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++) { - 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; tot_sent += sent; - if (sent != iov[i].iov_len) break; + if ((size_t) sent != iov[i].iov_len) break; } return tot_sent; }