Date: Thu, 26 Feb 2026 04:22:51 +0000 From: Dag-Erling=?utf-8?Q? Sm=C3=B8rg?=rav <des@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: cca6f5eadb79 - stable/14 - libfetch: Fail hard if interrupted while connecting Message-ID: <699fca9b.36990.1a140c64@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch stable/14 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=cca6f5eadb796b03379eb21f38c74ca46a64e45b commit cca6f5eadb796b03379eb21f38c74ca46a64e45b Author: Dag-Erling Smørgrav <des@FreeBSD.org> AuthorDate: 2026-02-21 01:18:15 +0000 Commit: Dag-Erling Smørgrav <des@FreeBSD.org> CommitDate: 2026-02-26 04:03:43 +0000 libfetch: Fail hard if interrupted while connecting This fixes an issue where the first address that DNS returns is blocked by a packet filter, so we hang for a while, then the user hits Ctrl-C, interrupting connect(2), whereupon we move on to the next address, get a connection, request the file, and return to fetch(1), which sees that SIGINT was caught and bails. Note that we make no attempt to enforce fetchTimeout in the connection phase, and never have. It's feasible, but non-trivial, so we'll leave it as an exercise for future us. PR: 293312 MFC after: 1 week Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D55406 (cherry picked from commit afbdcd402bb439bd3d487baaad63b68e95929265) --- lib/libfetch/common.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/libfetch/common.c b/lib/libfetch/common.c index bff83ed905f6..784da2d9e6a2 100644 --- a/lib/libfetch/common.c +++ b/lib/libfetch/common.c @@ -652,7 +652,13 @@ fetch_connect(const char *host, int port, int af, int verbose) goto syserr; } /* attempt to connect to server address */ - if ((err = connect(sd, sai->ai_addr, sai->ai_addrlen)) == 0) + while ((err = connect(sd, sai->ai_addr, sai->ai_addrlen)) < 0) { + if (errno == EINTR && fetchRestartCalls) + continue; + break; + } + /* success? */ + if (err == 0) break; /* clean up before next attempt */ close(sd);home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?699fca9b.36990.1a140c64>
