From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.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 gPECE0zgJGatXwAA62LTzQ:P1 (envelope-from ) for ; Sun, 21 Apr 2024 11:45:48 +0200 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id gPECE0zgJGatXwAA62LTzQ (envelope-from ) for ; Sun, 21 Apr 2024 11:45:48 +0200 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=1713692748; 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=86m4Lmjy5r6fFXn4B3MNJ/yrWIMOyokcrs2VsP1MRD8=; b=dExBZZ1NqbQ7U+OA+dQQFFc9PfqwVPf3KNiaBcVeruqcehlXrprR+/4mB+bnRbklF5AmsK wb1SFrg1j7z0o2NlJUTfFvSy9ep6LB/Wcg8qg1Hq6vb3BDsqD5f9mbHXE7D9hewBZZjJf/ SWChRzev6MwuQuqakme2fXFv4iZgoAjy9pFuFpkQeg6v31WusyM8TinodwtY4gNQ/f9yOn tc/ELIJlcYP0gfUXlxvKQSwFcwdO+s1LKXdyIJu8tq4slMP3mEnxZfBeCZBV67WSJ9FYFR 0RevHxj3MUCKtXQOdm+tLQgMeYX3Ancvc6eSa/JZoDBQ6//MNBa+9liwXNptTQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1713692748; a=rsa-sha256; cv=none; b=OF9l5MOmDD37MtzHEOJTGz9soF7kUg5/49E2xAVKh4hSiWGqblT75IMZug04vU9PZwLItx glWq5I9rQeetqV69vzeTQAF0yK4EOkKNWLRDMWDV/reQfun8o+mN5/6ix3swUNJHxguTPh R4xgfsmlzKA8RLBK+iAxqtTeA+xkMggpNxhzhw1uYycRk1FxUv5RUvKkwgtR2TZdvuMmoU YRLNi+cNFhR3DVgtHeVNj3BGh75mylrahhujo3oCzh6/t43POGKhnRfHvWVTi2C6a0ESS3 x8TV22jOE50TQwLuvVAems69+gwYTp29V7gNIoK+UKO/XQU9fCwT3trFlGK/mw== 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 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 302E01F4EF for ; Sun, 21 Apr 2024 11:45:48 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ryTk0-0005ch-DA; Sun, 21 Apr 2024 05:44:08 -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 1ryTjp-0005U0-Kq for guix-patches@gnu.org; Sun, 21 Apr 2024 05:43:58 -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 1ryTjp-0002qn-CG; Sun, 21 Apr 2024 05:43:57 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ryTk3-0006Wu-RC; Sun, 21 Apr 2024 05:44:11 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#70494] [PATCH 23/23] substitutes: Add #:keep-alive? keyword argument to 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: Sun, 21 Apr 2024 09:44:11 +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: 70494@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 70494-submit@debbugs.gnu.org id=B70494.171369264024835 (code B ref 70494); Sun, 21 Apr 2024 09:44:11 +0000 Received: (at 70494) by debbugs.gnu.org; 21 Apr 2024 09:44:00 +0000 Received: from localhost ([127.0.0.1]:41797 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ryTjr-0006SP-Ea for submit@debbugs.gnu.org; Sun, 21 Apr 2024 05:43:59 -0400 Received: from mira.cbaines.net ([212.71.252.8]:43376) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ryTj1-0006Ij-0W for 70494@debbugs.gnu.org; Sun, 21 Apr 2024 05:43:11 -0400 Received: from localhost (unknown [212.132.255.10]) by mira.cbaines.net (Postfix) with ESMTPSA id AA62227BBFA for <70494@debbugs.gnu.org>; Sun, 21 Apr 2024 10:42:49 +0100 (BST) Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id f81251cd for <70494@debbugs.gnu.org>; Sun, 21 Apr 2024 09:42:49 +0000 (UTC) From: Christopher Baines Date: Sun, 21 Apr 2024 10:42:41 +0100 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: <87bk632h36.fsf@cbaines.net> References: <87bk632h36.fsf@cbaines.net> 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-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -3.38 X-Spam-Score: -3.38 X-Migadu-Queue-Id: 302E01F4EF X-Migadu-Scanner: mx12.migadu.com X-TUID: 8JRHvFCC2tgX To be consistent with other procedures that make network requests. * guix/substitutes.scm (download-nar): Add #:keep-alive? option. * guix/scripts/substitute.scm (process-substitution/fallback, process-substitution): Call download-nar with #:keep-alive? #t. Change-Id: I83b27d0c3a0916d058fbbbeb7aa77dbb8a742768 --- guix/scripts/substitute.scm | 6 ++++-- guix/substitutes.scm | 11 +++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/guix/scripts/substitute.scm b/guix/scripts/substitute.scm index c74da618b5..68c24820c6 100755 --- a/guix/scripts/substitute.scm +++ b/guix/scripts/substitute.scm @@ -410,7 +410,8 @@ (define* (process-substitution/fallback narinfo destination #:prefer-fast-decompression? prefer-fast-decompression? #:open-connection-for-uri - open-connection-for-uri/cached)) + open-connection-for-uri/cached + #:keep-alive? #t)) (loop rest))) (() (loop rest))))))) @@ -463,7 +464,8 @@ (define* (process-substitution store-item destination #:print-build-trace? print-build-trace? #:prefer-fast-decompression? prefer-fast-decompression? #:open-connection-for-uri - open-connection-for-uri/cached)))) + open-connection-for-uri/cached + #:keep-alive? #t)))) (values narinfo expected-hash actual-hash))) diff --git a/guix/substitutes.scm b/guix/substitutes.scm index 5089f3a6da..7c8f8cc973 100644 --- a/guix/substitutes.scm +++ b/guix/substitutes.scm @@ -462,7 +462,8 @@ (define* (download-nar narinfo destination #:key deduplicate? print-build-trace? (fetch-timeout %fetch-timeout) prefer-fast-decompression? - (open-connection-for-uri guix:open-connection-for-uri)) + (open-connection-for-uri guix:open-connection-for-uri) + (keep-alive? #f)) "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." @@ -505,7 +506,7 @@ (define* (download-nar narinfo destination (raise c)))) (http-fetch uri #:text? #f #:port port - #:keep-alive? #t + #:keep-alive? keep-alive? #:buffered? #f))))) (else (raise @@ -586,6 +587,12 @@ (define* (download-nar narinfo destination ;; Wait for the reporter to finish. (every (compose zero? cdr waitpid) pids) + ;; TODO The port should also be closed if the relevant HTTP response + ;; header is set, but http-fetch doesn't currently share that + ;; information + (unless keep-alive? + (close-port raw)) + (values expected (get-hash))))) -- 2.41.0