From nobody Tue Jul 21 17:04:43 2026 X-Original-To: dev-commits-src-all@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 4h4NzJ2G1pz6mBtG 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 4h4NzH6Y9gz40WL 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=1784653483; 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=P+T59PzVtBJkL5NfnPKVv+OfgfadWlWRRyQMlCfrE/pwDey8wEkH4bbX6KBGZaF3X1gI/Z 84ozroV3jrygyCp3APaiHareHk9WR0NYGyblwzL9UFZRSOcsKliCgNcpK5cPcQpaiOEksa ixl13I1hInt+crVamgNa+CzirZkX058YxlEySXYNlDz1QMAFei1cbERfBELRLsqPQZ9Obi w3jXSMs+NSoYwA/Jfh2EprXPOj2BfJgLrbmjwKlrbc66Hnw4nvi+/Z4qualt1TG/CMWDdE qg6opteeqyD/85acG4wASRWTUl0af3CtU4XydTEG+6tZvVy0HpRcNNdUSwgnNQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1784653483; a=rsa-sha256; cv=none; b=t3ExklVUDDD9GvvHsNQ9tDL/fTO9doFyopQunMfdMoaoTW3BWzJ7geg/BjSr6zw/MwQ63Y bVVsQoHIbylNRbEGENsXj18WZK59y58DtxWU0/ApuTKoq6Vyzms0ZoIBRTIsI8KR/7zycG +seTxgs4KiPEH/iRh0yGjrnw//gLeqsY9QoHY+Mz0FluTMkTd/idSlASDKxek5PPOZQNvq ubvMQOncs9u5aYafK9pFpAv38u8JSRa9DCodpin0V4vccBlxBX8o5CJ7nsiCMeEtZsfgAD c68B4ezxFPoQmh61NuX7IuxflFJ167AAzSSColC/iNbjToi6o554MKrM6364qw== 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=1784653483; 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=VA5SnpeuyFVYB2KMS89oTWVPamMQQwBRwM8JYjI3e21NYxImGUY4TgBykm3wUXuJXxAPzr e7Hr/GQyEcvLv5WnyshSn7vDcnBabjRimLLd/1T00WY1wzxVP+UOy8WZaRbi74BGmzrCjG +iREgbYbLRslQcnOumr9RoBYUA9ShU/wLap8v4a41fCiHjk6AAOoklvUtVe7ic3kXGh/7i EUvbHVFyclEMbdZ6YkYCzgXaPU0d2KW/71rO70+0v982IGFj4Esp4hi5JPaEoNxa0KkB79 znFkOZhBDTzylKfjvQdOnYZbYRrxODQXK5x1wi9kCWbuxzyDd4IIcaRJjg2hXg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4h4NzH5K73zx79 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: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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;