Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 27 Jul 2026 23:11:00 +0000
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: b02e02958dad - main - libfetch: Fix handling of connection failures
Message-ID:  <6a67e584.32768.6fc20c11@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by markj:

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

commit b02e02958dad2d5ce3675cbc18b9a94635d09e66
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2026-07-27 18:58:34 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2026-07-27 23:03:16 +0000

    libfetch: Fix handling of connection failures
    
    After commit 848f360c8f9a, if one tries to connect to a closed port,
    fetch reports "Operation now in progress", which is rather confusing.
    Return a more useful error message, restoring the old behaviour.
    
    Fixes:          848f360c8f9a ("libfetch: Apply timeout to connection attempts")
    Reviewed by:    des
    MFC after:      3 days
    Differential Revision:  https://reviews.freebsd.org/D58481
---
 lib/libfetch/common.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/libfetch/common.c b/lib/libfetch/common.c
index dabc8c4b16b3..8ae51d37481b 100644
--- a/lib/libfetch/common.c
+++ b/lib/libfetch/common.c
@@ -681,6 +681,10 @@ fetch_connect(const char *host, int port, int af, int verbose)
 					    delta.tv_usec / 1000;
 				}
 			}
+			if (pfd.revents & POLLHUP) {
+				errno = ECONNREFUSED;
+				break;
+			}
 			if (pfd.revents == POLLOUT) {
 				/* connection established */
 				err = 0;


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a67e584.32768.6fc20c11>