From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms1.migadu.com with LMTPS id EGK8IRM0RmawEQEAe85BDQ:P1 (envelope-from ) for ; Thu, 16 May 2024 18:28:03 +0200 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id EGK8IRM0RmawEQEAe85BDQ (envelope-from ) for ; Thu, 16 May 2024 18:28:03 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=eMn29xGk; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1715876883; a=rsa-sha256; cv=none; b=taka9IYQf2w0evvNU3R+AgToat4SB0v9YIRdG2c1okXGo/hzNkKJ9gmaku+SqQ2o4so/A7 /D6jiufdowmLsCLEyQqOhjEnja1YteRf/M2I5SIgY6fseV5uHlxJHV9f3g4SH8OMC/ZE/u vf1vEmDKRXWtJDTM0Dr0sOa8/HQtlP+0WMa8I7EFQ1NeE7JpbJ3W3qK34+rw1R16zhVpEx MT9Ic+Q1DVT6ak03fDwa95AO4/iU1tsBP3m55ihG5+DQO25zRSqr7WxErgShqKZ9udT7GH MkJM/fDfXr+zY5liLIFo3Cbe+8IiABmj1uqbj0rR/mbSDLxYOZ4dViaUoZld0Q== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=eMn29xGk; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1715876883; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=MODIfA6FN4HKOMnU0Ieas0KNVRaZAaPiwXkhbuMglSg=; b=ID+1NuhS06D0XDiUKah5iZWk8h5MKSvY712YBMl64IJEDhabn5a7qEmRKsevFbbUBKbpdR o3NsNZPVsvijYt/wMLTnr4fVaVUCv90iJPpJs975mv8e55FGijp7ZYiWYKuDT3/76Xbboj iw05F8JaTBh9HTZ8LJEUc3izYEkagufY4pl7gOjuewv4q2kBicuRFKL3PxMMo/yWkkUFFH S5EdzXmydKyNB0j22he9xdj0tjByZTdZfXIiRwFogrJmGkimmLiZg4zxn2G3UKzH9NKG6R kGMtmwGMyvVYVcQG/Vcviolc7I/TLnySAPrBXTNbcTzSEr2/oAcKKlvGcxAY2w== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 695281F8BE for ; Thu, 16 May 2024 18:28:03 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s7dxZ-0003Vj-4d; Thu, 16 May 2024 12:28:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s7dxX-0003VU-Pb for guix-patches@gnu.org; Thu, 16 May 2024 12:27:59 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s7dxX-0004KW-HK for guix-patches@gnu.org; Thu, 16 May 2024 12:27:59 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1s7dxZ-0000Yo-JA for guix-patches@gnu.org; Thu, 16 May 2024 12:28:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#70494] [PATCH 20/23] scripts: substitute: Simplify with-timeout usage. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 16 May 2024 16:28:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70494 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Christopher Baines Cc: Josselin Poiret , 70494@debbugs.gnu.org, Simon Tournier , Mathieu Othacehe , Tobias Geerinckx-Rice , Ricardo Wurmus , Christopher Baines Received: via spool by 70494-submit@debbugs.gnu.org id=B70494.17158768522138 (code B ref 70494); Thu, 16 May 2024 16:28:01 +0000 Received: (at 70494) by debbugs.gnu.org; 16 May 2024 16:27:32 +0000 Received: from localhost ([127.0.0.1]:49708 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s7dx6-0000YQ-GM for submit@debbugs.gnu.org; Thu, 16 May 2024 12:27:32 -0400 Received: from eggs.gnu.org ([209.51.188.92]:43080) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s7dx3-0000YI-MO for 70494@debbugs.gnu.org; Thu, 16 May 2024 12:27:30 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s7dwv-0004Hr-RR; Thu, 16 May 2024 12:27:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=MODIfA6FN4HKOMnU0Ieas0KNVRaZAaPiwXkhbuMglSg=; b=eMn29xGktT/lawpeme+n /T1gPlwDJIC3AayjyzVf0F+TxPIOHcUZxy1LcHGnj0KsKFwirxpAHPPmTrvhsX6P6oKcHj27y/Qlb iMemQD5vDyRciuCGKez1xh2rwUdtCNM34r1B0/nZDyt3nDznWVcypWR6PLOHPmu0axbiNs5noo9uA CB76hwq9kLFV5a0NHM84gaEVmrCyZo3QDA7DxO9n0aaIQrgehBmksYZUACVS5nZv+KH8GW4YKwvXg 9NkqxZArSTffiBy3mPXNEvdG+oKJJ5CuJ5or7ojZ896UGM7yYyAFOf38pmTmpBgIfNMR6PYWQlVz5 hyao5UgHK8HyOA==; From: Ludovic =?UTF-8?Q?Court=C3=A8s?= In-Reply-To: <603b957f193b30f454d27070d1536aa6a7adaca9.1713692561.git.mail@cbaines.net> (Christopher Baines's message of "Sun, 21 Apr 2024 10:42:38 +0100") References: <87bk632h36.fsf@cbaines.net> <603b957f193b30f454d27070d1536aa6a7adaca9.1713692561.git.mail@cbaines.net> Date: Thu, 16 May 2024 18:27:14 +0200 Message-ID: <87fruh90yl.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Queue-Id: 695281F8BE X-Migadu-Scanner: mx12.migadu.com X-Migadu-Spam-Score: -5.77 X-Spam-Score: -5.77 X-TUID: mbG8jsUqPEsl Christopher Baines skribis: > To reduce the codepaths in download-nar. > > * guix/scripts/substitute.scm (with-timeout): Accept a #f duration and do= n't > set a timeout. > (download-nar): Remove the if for fetch-timeout. > > Change-Id: I4e944a425a8612e96659dd84dd0e315012f080ab [...] > (define-syntax-rule (with-timeout duration handler body ...) > "Run BODY; when DURATION seconds have expired, call HANDLER, and run B= ODY > again." The docstring needs updating. > + (if duration > + (begin > + (sigaction SIGALRM > + (lambda (signum) > + (sigaction SIGALRM SIG_DFL) > + handler)) > + (alarm duration) > + (call-with-values > + (lambda () > + (let try () > + (catch 'system-error > + (lambda () > + body ...) > + (lambda args > + ;; Before Guile v2.0.9-39-gfe51c7b, the SIGALRM trig= gers EINTR > + ;; because of the bug at > + ;; . > + ;; When that happens, try again. Note: SA_RESTART c= annot be > + ;; used because of . > + (if (=3D EINTR (system-error-errno args)) > + (begin > + ;; Wait a little to avoid bursts. > + (usleep (random 3000000 %random-state)) > + (try)) > + (apply throw args)))))) > + (lambda result > + (alarm 0) > + (sigaction SIGALRM SIG_DFL) > + (apply values result)))) > + (begin > + body ...))) To avoid code bloat due to expanding BODY twice, I think this should be something like: (let ((thunk (lambda () body ...))) (if duration =E2=80=A6 (thunk))) Otherwise LGTM.