From patchwork Sun Apr 21 09:42:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christopher Baines X-Patchwork-Id: 63262 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 1698B27BBE2; Sun, 21 Apr 2024 10:45:49 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id C35F227BBEB for ; Sun, 21 Apr 2024 10:45:47 +0100 (BST) 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 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+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches 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)))))