From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id KIXREsUA1WUnhgEA62LTzQ:P1 (envelope-from ) for ; Tue, 20 Feb 2024 20:43:01 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id KIXREsUA1WUnhgEA62LTzQ (envelope-from ) for ; Tue, 20 Feb 2024 20:43:01 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=none; 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"; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1708458181; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: 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; bh=V6X7kOsespm9imyqyIBbCsWzVj4U2cg5pifMT9JE0s0=; b=oMvxInkkL5o+ZHyD285s8dRqFVZjvXyp+iK+buCBzAoG3gndslGbaWxWZutEe3eUfz+UTQ k/Atfhv39oPixqPdmeiUFOr6zZ70mErzVMgKgAaJzPevwve4Kd/N4qPp8tMxFs5zd3fTTt Yl4udGgWb8TE9MbJyvKeAePgn/cnad+XgeJHQTC+Y1ZoCrANe6OcdbdK5msEqBDmSwZRra YSItOZnCAJHbvvk2hyuocP+XARs4xbE+ADMaQCJhGe1SLnZRTaCZ6Xj8XREM3p8L03qQ1A CD4KMsK25/wNMhRxVz27flVFuY4NmFqfnPYQXPzFGaI5eK6ebf3sj/x+MK0dqA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; 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"; dmarc=none ARC-Seal: i=1; s=key1; d=yhetil.org; t=1708458181; a=rsa-sha256; cv=none; b=EREQSLtSCKLpmLN7IHybpnO1QaMxAovD+i5UGQaseuukiOa3/IzeNdSbjQn/YEpL2m7Xvn fpEFegugaA+8rhGUoJBn5oQS2GV85om2JguvwzuCbnhTiLQA1v+QvJ4q93jOlpIcDUs0A/ 8PWUsGp62EJ/POjhXtR1LJDBZQTXJ6UcOtaP5tyxL68jLptbhBUeHSamOlNvwdGbEkBiZF XVDyK5+Be6JLUXtph2bZMNoE5RdTUe+gJE7LlB1J2AF+8Fo4a5s37OLgeoQE3iWgFihUPd yKjanZobmCZOI6ge6CzqQFYu53Ec+J3ReYm0UmtaHKcSVZLyEvWCg4idxMe1pQ== 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 3577545919 for ; Tue, 20 Feb 2024 20:43:01 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcW0q-0004Cx-Oc; Tue, 20 Feb 2024 14:42:44 -0500 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 1rcW0o-0004Bt-RE for guix-patches@gnu.org; Tue, 20 Feb 2024 14:42:42 -0500 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 1rcW0o-000164-Id; Tue, 20 Feb 2024 14:42:42 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rcW18-0002Z7-6X; Tue, 20 Feb 2024 14:43:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#69291] [PATCH 2/5] scripts: substitute: Allow not using with-timeout in download-nar. Resent-From: Christopher Baines Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, rekado@elephly.net, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Tue, 20 Feb 2024 19:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69291 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 69291@debbugs.gnu.org Cc: Christopher Baines , Josselin Poiret , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 69291-submit@debbugs.gnu.org id=B69291.17084581769825 (code B ref 69291); Tue, 20 Feb 2024 19:43:02 +0000 Received: (at 69291) by debbugs.gnu.org; 20 Feb 2024 19:42:56 +0000 Received: from localhost ([127.0.0.1]:46673 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rcW0z-0002YA-7l for submit@debbugs.gnu.org; Tue, 20 Feb 2024 14:42:55 -0500 Received: from mira.cbaines.net ([212.71.252.8]:43156) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rcW0x-0002Xp-As for 69291@debbugs.gnu.org; Tue, 20 Feb 2024 14:42:51 -0500 Received: from localhost (unknown [212.132.255.10]) by mira.cbaines.net (Postfix) with ESMTPSA id F204C27BBE9 for <69291@debbugs.gnu.org>; Tue, 20 Feb 2024 19:42:28 +0000 (GMT) Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id 6addb520 for <69291@debbugs.gnu.org>; Tue, 20 Feb 2024 19:42:28 +0000 (UTC) From: Christopher Baines Date: Tue, 20 Feb 2024 19:42:24 +0000 Message-ID: <2bcc2278b5aefcd81fbc53b791d08622b6d93c7c.1708458147.git.mail@cbaines.net> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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-Spam-Score: -3.48 X-Spam-Score: -3.48 X-Migadu-Queue-Id: 3577545919 X-Migadu-Scanner: mx11.migadu.com X-TUID: jz/5VGqMFUNu I don't think the approach of using SIGALARM here for the timeout will work well in all cases (e.g. when using Guile Fibers), so make it possible to avoid this. * guix/scripts/substitute.scm (download-nar): Pass the fetch timeout in as an option. Change-Id: I8cbe6cdfa10cdaa7d41974cbea56a95f5efecfe6 --- guix/scripts/substitute.scm | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/guix/scripts/substitute.scm b/guix/scripts/substitute.scm index f3eed0eb44..575fa2a0b3 100755 --- a/guix/scripts/substitute.scm +++ b/guix/scripts/substitute.scm @@ -452,7 +452,8 @@ (define-syntax-rule (catch-system-error exp) (define* (download-nar narinfo destination #:key status-port - deduplicate? print-build-trace?) + deduplicate? print-build-trace? + (fetch-timeout %fetch-timeout)) "Download the nar prescribed in NARINFO, which is assumed to be authentic and authorized, and write it to DESTINATION. When DEDUPLICATE? is true, and if DESTINATION is in the store, deduplicate its files. Print a status line to @@ -473,20 +474,26 @@ (define* (download-nar narinfo destination (let ((port (open-file (uri-path uri) "r0b"))) (values port (stat:size (stat port))))) ((http https) - ;; Test this with: - ;; sudo tc qdisc add dev eth0 root netem delay 1500ms - ;; and then cancel with: - ;; sudo tc qdisc del dev eth0 root - (with-timeout %fetch-timeout - (begin - (warning (G_ "while fetching ~a: server is somewhat slow~%") - (uri->string uri)) - (warning (G_ "try `--no-substitutes' if the problem persists~%"))) - (with-cached-connection uri port - (http-fetch uri #:text? #f - #:port port - #:keep-alive? #t - #:buffered? #f)))) + (if fetch-timeout + ;; Test this with: + ;; sudo tc qdisc add dev eth0 root netem delay 1500ms + ;; and then cancel with: + ;; sudo tc qdisc del dev eth0 root + (with-timeout %fetch-timeout + (begin + (warning (G_ "while fetching ~a: server is somewhat slow~%") + (uri->string uri)) + (warning (G_ "try `--no-substitutes' if the problem persists~%"))) + (with-cached-connection uri port + (http-fetch uri #:text? #f + #:port port + #:keep-alive? #t + #:buffered? #f))) + (with-cached-connection uri port + (http-fetch uri #:text? #f + #:port port + #:keep-alive? #t + #:buffered? #f)))) (else (leave (G_ "unsupported substitute URI scheme: ~a~%") (uri->string uri))))) -- 2.41.0