From nobody Tue Jul 21 17:04:43 2026 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4h4NzJ2CkWz6mBtF for ; Tue, 21 Jul 2026 17:04:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4h4NzH6Y8Nz40Sl for ; Tue, 21 Jul 2026 17:04:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1784653484; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=UXHDjcag/D/dc3J4jqoBeiMabD2CPXVEjdrpHoGz1cU=; b=tfNn8OROgbIb+gH1O17JnqwuXWZgASuiqD6UTflsTbVTozsVciZkhk3jmQp1UNkxti3r0B 6hHUB9SlhcyH07+2rwI8GYyo3wXhV7qP3v2JahmmFsmF4kkrYd1JDPBvAFHH/GZYQCcXrd hpIWsnu8EvsiOt4MVcjhT0KSTars4ogfDMNwNMeerocDU/GGiyJHTLT9dLstNMV4oPX3/Z +A2FW+Fb85BRl78r+B+SHpOHQjGsL030Z0itsoHYlBKlCl6ZIk3xPLIJI7kt80JU8HqUmS yO5twHfBBsozvnifw/j4PC5XfsJAfv3Y6ERwFXO7ij+Qcdt6LV2PQqMTX4oUhQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1784653484; a=rsa-sha256; cv=none; b=jBTQCKLvFnEQ2hnI3fx4KgHFA3feRi2J/Qk951UylJ05ZnJ6zd09Na4yUwmBQZHcC8hWWR yZ8rx9asU5fRW4CWkxetKaQbo5F9wew4mk0vrRIGal+lF85Um3ENkiz7+QIy+YooXK2gFK M2q8oLsjtWUNRFpO1b8CWSqwkQaYHHXkJ63GcMhkUjYCgEoYWluzM7IouJQTIA8gUobStY WeJOxCt3S5Agk6oNzd/i1EZqay2YMJewUUGzVHJf/hopiiXaoEJrpJATJuhlf3pqccd6+q 4zo0+LpBIMWPId4fBptP/6JGUDRjAqwR0DwAaoVve7O4wm5NIWISwsxFelR+6w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1784653484; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=UXHDjcag/D/dc3J4jqoBeiMabD2CPXVEjdrpHoGz1cU=; b=jea3XvFWVq0Ous3BCUUNwffrud6Gq6quOziMCJAT9fndQ+xus5KgXXTm0eGFgrfr3F/veb 6AlOe5DRLBgfff0oqTRtjTfDNyyRq3OsWXVwYCZQp+uX//QZ4c/cbch70tpGLX86Ij8YcP a7TTiQ1lxxUp2IHg4ihit/RAiQzsl7oel+l0U+Ej0x5pnT2gan9lAH80/JzSS8iPHB74xP IFjTunpaehKs1qceQJp3HvH3Seku20kfJ9nIVKB+FEGdznCIcMEAnSmCGU5g9vOASNiqxk zd0AspJyp9z+5sQF3Q7HlBg/yAgSk5RtanVj7UsZZSjwZ78D3dcU+i0rV8owEA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4h4NzH5K9QzxSn for ; Tue, 21 Jul 2026 17:04:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3695a by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 21 Jul 2026 17:04:43 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dag-Erling=?utf-8?Q? Sm=C3=B8rg?=rav Subject: git: 29564d956bc2 - stable/14 - fetch: Stop setting an alarm List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: des X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 29564d956bc2e2248d0e10b44471435bb96b7ad9 Auto-Submitted: auto-generated Date: Tue, 21 Jul 2026 17:04:43 +0000 Message-Id: <6a5fa6ab.3695a.7370a9c5@gitrepo.freebsd.org> The branch stable/14 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=29564d956bc2e2248d0e10b44471435bb96b7ad9 commit 29564d956bc2e2248d0e10b44471435bb96b7ad9 Author: Dag-Erling Smørgrav AuthorDate: 2026-07-13 06:43:46 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2026-07-21 17:04:28 +0000 fetch: Stop setting an alarm Now that fetchTimeout works reliably, setting an alarm is not only no longer necessary but counterproductive, as it will trigger even if the connection is not actually stalled but merely slow. While here, improve the wording of the manual page's description of the various options for setting a timeout. MFC after: 1 week Reviewed by: op Differential Revision: https://reviews.freebsd.org/D57911 (cherry picked from commit 3dddfe29248c47d1a80dc96a76a308ae910b2a24) --- usr.bin/fetch/fetch.1 | 10 ++++++---- usr.bin/fetch/fetch.c | 33 +++++++++------------------------ 2 files changed, 15 insertions(+), 28 deletions(-) diff --git a/usr.bin/fetch/fetch.1 b/usr.bin/fetch/fetch.1 index 7238226998fc..17b96d8d459b 100644 --- a/usr.bin/fetch/fetch.1 +++ b/usr.bin/fetch/fetch.1 @@ -28,7 +28,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd October 7, 2023 +.Dd June 27, 2026 .Dt FETCH 1 .Os .Sh NAME @@ -283,7 +283,7 @@ ignored and the file is fetched unconditionally. .It Fl s , -print-size Print the size in bytes of each requested file, without fetching it. .It Fl T Ar seconds , Fl -timeout= Ns Ar seconds -Set timeout value to +Set the network timeout to .Ar seconds . Overrides the environment variables .Ev FTP_TIMEOUT @@ -322,9 +322,11 @@ message. .Sh ENVIRONMENT .Bl -tag -width HTTP_TIMEOUT .It Ev FTP_TIMEOUT -Maximum time, in seconds, to wait before aborting an FTP connection. +Maximum time, in seconds, to wait before giving up on a stalled FTP +transfer. .It Ev HTTP_TIMEOUT -Maximum time, in seconds, to wait before aborting an HTTP connection. +Maximum time, in seconds, to wait before giving up on a stalled HTTP +transfer. .El .Pp See diff --git a/usr.bin/fetch/fetch.c b/usr.bin/fetch/fetch.c index d800ebf59f11..493a73f5dc9b 100644 --- a/usr.bin/fetch/fetch.c +++ b/usr.bin/fetch/fetch.c @@ -88,7 +88,6 @@ static pid_t pgrp; /* our process group */ static long w_secs; /* -w: retry delay */ static int family = PF_UNSPEC; /* -[46]: address family to use */ -static int sigalrm; /* SIGALRM received */ static int siginfo; /* SIGINFO received */ static int sigint; /* SIGINT received */ @@ -174,9 +173,6 @@ static void sig_handler(int sig) { switch (sig) { - case SIGALRM: - sigalrm = 1; - break; case SIGINFO: siginfo = 1; break; @@ -437,6 +433,7 @@ fetch(char *URL, const char *path, int *is_http) char *tmppath; int r, tries; unsigned timeout; + int timedout = 0; char *ptr; f = of = NULL; @@ -520,13 +517,7 @@ fetch(char *URL, const char *path, int *is_http) /* just print size */ if (s_flag) { - if (timeout) - alarm(timeout); r = fetchStat(url, &us, flags); - if (timeout) - alarm(0); - if (sigalrm || sigint) - goto signal; if (r == -1) { warnx("%s", fetchLastErrString); goto failure; @@ -575,13 +566,7 @@ again: size_prev = sb.st_size; /* start the transfer */ - if (timeout) - alarm(timeout); f = fetchXGet(url, &us, flags); - if (timeout) - alarm(0); - if (sigalrm || sigint) - goto signal; if (f == NULL) { if (i_flag && *is_http && fetchLastErrCode == FETCH_OK && strcmp(fetchLastErrString, "Not Modified") == 0) { @@ -749,7 +734,7 @@ again: /* start the counter */ stat_start(&xs, path, us.size, count); - sigalrm = siginfo = sigint = 0; + siginfo = sigint = 0; /* suck in the data */ setvbuf(f, NULL, _IOFBF, B_size); @@ -786,8 +771,7 @@ again: if (readcnt != 0) break; } - if (!sigalrm) - sigalrm = ferror(f) && errno == ETIMEDOUT; + timedout = ferror(f) && errno == ETIMEDOUT; signal(SIGINFO, SIG_DFL); stat_end(&xs); @@ -812,18 +796,20 @@ again: } /* timed out or interrupted? */ - if (sigalrm) + if (timedout) { warnx("transfer timed out"); + goto failure; + } if (sigint) { warnx("transfer interrupted"); goto failure; } - /* timeout / interrupt before connection completley established? */ + /* timeout / interrupt before connection completely established? */ if (f == NULL) goto failure; - if (!sigalrm) { + if (!timedout) { /* check the status of our files */ if (ferror(f)) warn("%s", URL); @@ -851,7 +837,7 @@ again: * If the transfer timed out and we didn't know how much to * expect, assume the worst (i.e. we didn't get all of it) */ - if (sigalrm && us.size == -1) { + if (timedout && us.size == -1) { warnx("%s may be truncated", path); goto failure_keep; } @@ -1127,7 +1113,6 @@ main(int argc, char *argv[]) sa.sa_flags = 0; sa.sa_handler = sig_handler; sigemptyset(&sa.sa_mask); - sigaction(SIGALRM, &sa, NULL); sa.sa_flags = SA_RESETHAND; sigaction(SIGINT, &sa, NULL); fetchRestartCalls = 0;