From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id sw3wHl62smBzagEAgWs5BA (envelope-from ) for ; Sat, 29 May 2021 23:47:10 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id wKKXGV62smC8fQAAB5/wlQ (envelope-from ) for ; Sat, 29 May 2021 21:47:10 +0000 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 E78BB1F07D for ; Sat, 29 May 2021 23:47:09 +0200 (CEST) Received: from localhost ([::1]:46424 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ln6nU-00080r-K7 for larch@yhetil.org; Sat, 29 May 2021 17:47:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34476) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ln6nO-00080S-Gl for guix-patches@gnu.org; Sat, 29 May 2021 17:47:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:46314) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ln6nO-0002ya-9O for guix-patches@gnu.org; Sat, 29 May 2021 17:47:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ln6nO-0004Os-7R for guix-patches@gnu.org; Sat, 29 May 2021 17:47:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#47174] [PATCH 0/2] substitute: Handle closing connections to substitute servers. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 29 May 2021 21:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47174 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Christopher Baines Cc: 47174@debbugs.gnu.org Received: via spool by 47174-submit@debbugs.gnu.org id=B47174.162232479616882 (code B ref 47174); Sat, 29 May 2021 21:47:02 +0000 Received: (at 47174) by debbugs.gnu.org; 29 May 2021 21:46:36 +0000 Received: from localhost ([127.0.0.1]:57860 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ln6mx-0004OE-LF for submit@debbugs.gnu.org; Sat, 29 May 2021 17:46:35 -0400 Received: from eggs.gnu.org ([209.51.188.92]:40692) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ln6mw-0004O1-1l for 47174@debbugs.gnu.org; Sat, 29 May 2021 17:46:34 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:55930) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ln6mq-0002ca-Bi; Sat, 29 May 2021 17:46:28 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=41668 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ln6mq-0003UE-1U; Sat, 29 May 2021 17:46:28 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <20210520120413.21644-1-mail@cbaines.net> <20210520120413.21644-2-mail@cbaines.net> Date: Sat, 29 May 2021 23:46:26 +0200 In-Reply-To: <20210520120413.21644-2-mail@cbaines.net> (Christopher Baines's message of "Thu, 20 May 2021 13:04:13 +0100") Message-ID: <87tuml43il.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) 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" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1622324830; 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; bh=ZW8WJnKQb6OdnY7FF9VeCkm8jHP1l3q+DneLBEC9Y3E=; b=F5Jgf2m6VcMD3je8Ob0Nb8ZU5FyE2DBsrhFnnrCV9xpnAZ0oR5ylw1kQ98CwtDy4tcH2ut /4bSI9J2DsVLf1suuFVmu1IyQ1IMBlUp0LJVrIE/wX7xLb1xOjZzlI1SHVgBaJoicBV+HQ RpDIFbmzw8FqoEXWVYrQ9JU33Z+B62GPgd65wEJWfvsjfLctpQIiODpBBagEV3HNe4Tf0z kBZQ/NEzMZPBE6EZ2h2s41rd/Cjimy8OXfjO8FKI3Sr3gm7nImMXaigSOZfepVkC+lUcvA iC6aoXpswTQjeaosqmIu6DWQOQ9Zv/JNki6pn0mFWdl0/8D1HDLQXelGPmH+4g== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1622324830; a=rsa-sha256; cv=none; b=J/QF8e7BTnVfMoZE2XDK6k16AqWajctBXottXkIgB6TWbvSQ9VHwBZF8ORjxhaH7BThUnp aBjJjebxwqEQVqI52hk55vowMucE1GzOrssDq9J9l+3+bnBhxyBV8o3w6KPMXBuZzg+zZg dxVMQV7nT36XJ3rDYZ7KIDMbh20VhTZsxvqYBX7pv3Ua8DzgxatV+KJeuFaLw1ArJPBak6 sXiYECdOb4QGeeO43/w1TlkjJP/g8Ud4jlc4AizpX1diDBS9uYdCLkgvtdrScit8WXcixW SJWDYPvOmaiX4akNsoZW/UX5NRRcrKkAcQ2nWm6rAi2HgHuyQeUXuEFaHJXTLQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: -2.93 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: E78BB1F07D X-Spam-Score: -2.93 X-Migadu-Scanner: scn0.migadu.com X-TUID: NRBZZKordztZ Christopher Baines skribis: > When reusing a HTTP connection to fetch multiple nars, and the remote ser= ver > signals that the connection should be closed. Incomplete sentence? > * guix/scripts/substitute.scm (process-substitution): Close connections to > substitute servers when a Connection: close header is specified in the > response. > --- > guix/scripts/substitute.scm | 17 ++++++++++++++--- > 1 file changed, 14 insertions(+), 3 deletions(-) > > diff --git a/guix/scripts/substitute.scm b/guix/scripts/substitute.scm > index 96f425eaa0..208b8f1273 100755 > --- a/guix/scripts/substitute.scm > +++ b/guix/scripts/substitute.scm > @@ -464,7 +464,9 @@ PORT." > (case (uri-scheme uri) > ((file) > (let ((port (open-file (uri-path uri) "r0b"))) > - (values port (stat:size (stat port))))) > + (values port > + (stat:size (stat port)) > + (const #t)))) ; no cleanup to do > ((http https) > (guard (c ((http-get-error? c) > (leave (G_ "download from '~a' failed: ~a, ~s~%") > @@ -487,7 +489,12 @@ PORT." > #:keep-alive? #t > #:buffered? #f))) > (values raw > - (response-content-length response))))))) > + (response-content-length response) > + (match (assq 'connection (response-headers respon= se)) > + (('connection 'close) > + (lambda () > + (close-port port))) > + (_ (const #t))))))))) > (else > (leave (G_ "unsupported substitute URI scheme: ~a~%") > (uri->string uri))))) > @@ -504,7 +511,7 @@ PORT." > (format (current-error-port) > (G_ "Downloading ~a...~%") (uri->string uri))) >=20=20 > - (let*-values (((raw download-size) > + (let*-values (((raw download-size post-fetch-cleanup) > ;; 'guix publish' without '--cache' doesn't specify a > ;; Content-Length, so DOWNLOAD-SIZE is #f in this cas= e. > (fetch uri)) > @@ -565,6 +572,10 @@ PORT." > ;; Wait for the reporter to finish. > (every (compose zero? cdr waitpid) pids) >=20=20 > + ;; Do post-fetch cleanup, maybe closing the HTTP connection if HTT= P is > + ;; being used, and the connection should be closed > + (post-fetch-cleanup) How about returning a Boolean as the third value, =E2=80=98close?=E2=80=99,= indicating whether the port should be closed upon completion? That seems marginally clearer to me that the post-cleanup thunk. Otherwise LGTM, thanks! Ludo=E2=80=99.