From nobody Tue Jul 21 17:04:31 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 4h4Nz458rFz6mC6v for ; Tue, 21 Jul 2026 17:04:32 +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 4h4Nz43sqPz3ypS for ; Tue, 21 Jul 2026 17:04:32 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1784653472; 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=v3eZVB2+1YAm5TbDSGNq4B2qQDaA41j+wT9bev0IjPE=; b=MElFao2/siXdkTRIjmxRRunx4KVG3fGR6jE6fP66Nm/UEev1OobXET9hy4eV4qKiUDsydR CV8YB/SC7Hf30VrJpHmflXacR+73K9WvZsUNh37dmPGxEzFDjK61WGFoBwcJu5Cq1oni+F vk4wtvViPHb68VPGnW2CDC7CAoxn2idUpereckxu4vQUknciMNPlZ9eLnfUHW4sLFiblFI SfzkV/adMGFg9jd0+nl1n3C7Vb6BUnR35kZ+qsvAr7y3HnK5uNjOCK1JhlJcke8mg4kV04 JgJwiEJL+kALhySseNPI8nJwuLdo3z6z8gBGJEueNVsVbwZ0U0uZgcHSKFFKbg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1784653472; a=rsa-sha256; cv=none; b=IavUUZ0Vi/Pe8RYPcPEf0poxHMUXLDICw0yvvIb+H67k7bT7YHTqYJkTjxP6sAH3raSVHD 11mCQbVMbUxhZSDT8LNVB/6Oi50KHA9O2Q6WN2mlqfn8idiyRtxKFeSmsDis+DYjNb4Tvu fFeFV48iRvT7E+1nFjWFiUM4M0yLeCVVghE4TKlvAyGX4V5JFaKajDRV4UKv/R5ZWbIReP r9BCp4A16ZARlfH8yHIge75jJpwOYpsort4QypgTAWfLVp9C1/nUFaFRgCjDG4sz2wMFfW usYQpxA8obVITaLjzIXaRxB+kGk5MCs7PxyLC1lNVxRIPdjwutrRtd1PM7Upzw== 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=1784653472; 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=v3eZVB2+1YAm5TbDSGNq4B2qQDaA41j+wT9bev0IjPE=; b=Ggz9LgoUYQ2obr0hlvy+sj8TsrTu1Hs+rT14zoABFA1mw8jeQ38zmQ41WH03sbmzzzsmqN /bKNt8P8Dx4C9lk9H4rjQ+GCy+iTD3yHy/sr/UWZuKU4EH4n2d0eNeNYN54edb0NybiiPo ccF7D4+3XU2aBHV50D90lT5q69GnCnxSl/UZWd8d00gIS7418mOwjhWPnHTqlPjBbtKmq5 7PIY2Wyipp5J7uKhIFB7fruZ+HUXiCNTomCSlzuc7HDH4eIOQba8+yjsxAS8xgPasalFuL WPfm7fLrHxi/xg+P+IzNBlt2BobnbsplXNroeDj/FrHtkNdx93kFLZQuI4OtmA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4h4Nz374sQzxSk for ; Tue, 21 Jul 2026 17:04:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 366a6 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 21 Jul 2026 17:04:31 +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: 98bfed530cbf - stable/15 - 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/15 X-Git-Reftype: branch X-Git-Commit: 98bfed530cbf860a5c729d97adf42628cefb55cb Auto-Submitted: auto-generated Date: Tue, 21 Jul 2026 17:04:31 +0000 Message-Id: <6a5fa69f.366a6.49479b7c@gitrepo.freebsd.org> The branch stable/15 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=98bfed530cbf860a5c729d97adf42628cefb55cb commit 98bfed530cbf860a5c729d97adf42628cefb55cb Author: Dag-Erling Smørgrav AuthorDate: 2026-07-13 06:43:46 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2026-07-21 17:03:38 +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 5e4b14289ca7..4e2a7596e796 100644 --- a/usr.bin/fetch/fetch.c +++ b/usr.bin/fetch/fetch.c @@ -87,7 +87,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 */ @@ -173,9 +172,6 @@ static void sig_handler(int sig) { switch (sig) { - case SIGALRM: - sigalrm = 1; - break; case SIGINFO: siginfo = 1; break; @@ -436,6 +432,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; @@ -519,13 +516,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; @@ -574,13 +565,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) { @@ -748,7 +733,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); @@ -785,8 +770,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); @@ -811,18 +795,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); @@ -850,7 +836,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; } @@ -1126,7 +1112,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;