aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Grosbein <eugen@FreeBSD.org>2026-01-22 08:40:35 +0000
committerEugene Grosbein <eugen@FreeBSD.org>2026-01-25 04:13:02 +0000
commitfae1c84e95f7be4deacdab8a97f140714d8d2ae8 (patch)
treec69fc8a5c5499f0e20d71ef222114d3942c60c6f
parente4730bb6bbd703ae20b73922bb394c4038681b16 (diff)
MFC: libfetch: apply timeout to SSL_read()
Currently, fetchTimeout works for non-SSL connections only, so does fetch -T. Fix it applying specified timeout to SSL_read(). (cherry picked from commit 8f8a7f6fffd7dca09013f7c4bfa075bc3825fb8e)
-rw-r--r--lib/libfetch/common.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/libfetch/common.c b/lib/libfetch/common.c
index 22779876ded4..9721cc557b53 100644
--- a/lib/libfetch/common.c
+++ b/lib/libfetch/common.c
@@ -1266,6 +1266,14 @@ fetch_ssl_read(SSL *ssl, char *buf, size_t len)
{
ssize_t rlen;
int ssl_err;
+ struct timeval tv;
+
+ if (fetchTimeout > 0) {
+ tv.tv_sec = fetchTimeout;
+ tv.tv_usec = 0;
+ setsockopt(SSL_get_fd(ssl), SOL_SOCKET, SO_RCVTIMEO,
+ &tv, sizeof(tv));
+ }
rlen = SSL_read(ssl, buf, len);
if (rlen < 0) {