The branch stable/13 has been updated by des:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=589cef5d51512782cee8b4562a62e70c654a7427

commit 589cef5d51512782cee8b4562a62e70c654a7427
Author:     Dag-Erling Smørgrav <[email protected]>
AuthorDate: 2026-02-18 15:10:47 +0000
Commit:     Dag-Erling Smørgrav <[email protected]>
CommitDate: 2026-02-18 18:41:17 +0000

    libfetch: Restore timeout functionality
    
    PR:             293124
    MFC after:      1 week
    Fixes:          792ef1ae7b94 ("Refactor fetch_connect() and fetch_bind() to 
improve readability and avoid repeating the same DNS lookups.")
    Reverts:        8f8a7f6fffd7 ("libfetch: apply timeout to SSL_read()")
    Reviewed by:    eugen, imp
    Differential Revision:  https://reviews.freebsd.org/D55293
    
    (cherry picked from commit 73b82d1b0a2f09224e6d0f7a13dd73c66d740207)
    (insta-mfc requested by re@)
---
 lib/libfetch/common.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/lib/libfetch/common.c b/lib/libfetch/common.c
index ca5022df38b4..008185720f16 100644
--- a/lib/libfetch/common.c
+++ b/lib/libfetch/common.c
@@ -278,13 +278,18 @@ conn_t *
 fetch_reopen(int sd)
 {
        conn_t *conn;
-       int opt = 1;
+       int flags, opt = 1;
 
        /* allocate and fill connection structure */
        if ((conn = calloc(1, sizeof(*conn))) == NULL)
                return (NULL);
-       fcntl(sd, F_SETFD, FD_CLOEXEC);
-       setsockopt(sd, SOL_SOCKET, SO_NOSIGPIPE, &opt, sizeof opt);
+       flags = fcntl(sd, F_GETFD);
+       if (flags != -1 && (flags & FD_CLOEXEC) == 0)
+               (void)fcntl(sd, F_SETFD, flags | FD_CLOEXEC);
+       flags = fcntl(sd, F_GETFL);
+       if (flags != -1 && (flags & O_NONBLOCK) == 0)
+               (void)fcntl(sd, F_SETFL, flags | O_NONBLOCK);
+       (void)setsockopt(sd, SOL_SOCKET, SO_NOSIGPIPE, &opt, sizeof(opt));
        conn->sd = sd;
        ++conn->ref;
        return (conn);
@@ -1269,14 +1274,6 @@ 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) {

Reply via email to