From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id iCPMI1slUWDiQQAA0tVLHw (envelope-from ) for ; Tue, 16 Mar 2021 21:38:35 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id cIWBH1slUWAaVAAAbx9fmQ (envelope-from ) for ; Tue, 16 Mar 2021 21:38:35 +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 3934E15E33 for ; Tue, 16 Mar 2021 22:38:35 +0100 (CET) Received: from localhost ([::1]:40626 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lMHOb-0005vM-QC for larch@yhetil.org; Tue, 16 Mar 2021 17:38:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56262) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMHHK-0000HM-0a for guix-patches@gnu.org; Tue, 16 Mar 2021 17:31:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:57909) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lMHHJ-00029L-Po for guix-patches@gnu.org; Tue, 16 Mar 2021 17:31:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lMHHJ-0004DW-N1 for guix-patches@gnu.org; Tue, 16 Mar 2021 17:31:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#47160] [PATCH] scripts: substitute: Add back some error handling. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 16 Mar 2021 21:31:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47160 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Christopher Baines Cc: 47160@debbugs.gnu.org Received: via spool by 47160-submit@debbugs.gnu.org id=B47160.161593023616173 (code B ref 47160); Tue, 16 Mar 2021 21:31:01 +0000 Received: (at 47160) by debbugs.gnu.org; 16 Mar 2021 21:30:36 +0000 Received: from localhost ([127.0.0.1]:41222 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lMHGr-0004Cj-0z for submit@debbugs.gnu.org; Tue, 16 Mar 2021 17:30:36 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34796) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lMHGm-0004CT-19 for 47160@debbugs.gnu.org; Tue, 16 Mar 2021 17:30:31 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:48375) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lMHGg-0001sF-Nq; Tue, 16 Mar 2021 17:30:22 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=44446 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1lMHGf-0002LB-53; Tue, 16 Mar 2021 17:30:22 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <20210315151133.16282-1-mail@cbaines.net> <20210315161532.1716-1-mail@cbaines.net> Date: Tue, 16 Mar 2021 22:30:19 +0100 In-Reply-To: <20210315161532.1716-1-mail@cbaines.net> (Christopher Baines's message of "Mon, 15 Mar 2021 16:15:31 +0000") Message-ID: <87k0q67pn8.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (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=1615930715; 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=bD+B28nhCwLc1vAlYqbx4CHXBHF+hS3x+58H1AlHIHM=; b=RWg8AlyGJydSMs+bP+V2LZrxiq18OUd0WQW/5vZQ6tHCvNIQO93fGMQ3cc5EmB6WCBtXSR eSsIPnPC+aSs3i88VSG5TaZZt9vjf6VFTwzj3fQyM4yzr8ns85YX4OvGGDBllLlI/0GkRR XS4isOTOwfoXGfUX51SrBWKMYPiJrQ1k1nYdLP/L+GYzkIpgq0kRjhWSJsWUfToyPtYwzT EwlKz72q4jPnQv6P+6AB9SBV7QCz+Ey975Kwa7TXuxuYp0+TqiZe+1oh2HDWFIOrSrLLg7 Q87G0GjSS5Ij7rsKuEkuSJQP04RxDfmM8L1QXHKB7YaexB7x6FwqdIDEssCuFw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1615930715; a=rsa-sha256; cv=none; b=a3EjWDOkK+zPcJfaIvNHkW2UGJwBSRniiP6sHnqwtlsUJfrABiT9v03BdKKI8atsZxSG8W 5OUuV7Pp/KvGWNuRJVpGa95i6Z9nqiMh0cHb2IkZMyT3+JsUJodOHTzuNCIZdPPgmXGSDh N/5ZXjVBZqvHkYbIZLBJoUNA6mytptF3bULz6bPPZqKG7L5/extrKX9983Yv/EcRXqoaVB VWk0YKvPOdDdILmr/emaiPRP80dflNSRMTG4gPlWr4pGqxHhnjN4JMJBw9c/u+aXyKhWnS QBu04OZLSP6gh3wMqXzLr7akf0DE91VuThf6bpXkLqdMDsWKh+m4scr4zUbBrQ== ARC-Authentication-Results: i=1; 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-Spam-Score: -2.90 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: 3934E15E33 X-Spam-Score: -2.90 X-Migadu-Scanner: scn0.migadu.com X-TUID: SgOki5bgwvp3 Christopher Baines skribis: > In f50f5751fff4cfc6d5abba9681054569694b7a5c, the way fetch was called wit= hin > process-substitution was changed. As with-cached-connection actually inc= ludes > important error handling for the opening of a HTTP request (when using a > cached connection), this change removed some error handling. > > This commit adds that error handling back, > (call-)with-cached-connection is back, rebranded as > call-with-cached-connection-and-error-handling. > > * guix/scripts/substitute.scm (process-substitution): Retry once for some > errors when making HTTP requests to fetch substitutes. Please mention also the new procedure, and a =E2=80=9CFixes .=E2=80=9D line > +(define (call-with-cached-connection-and-error-handling uri proc) > + (define (get-port) > + (open-connection-for-uri/cached uri > + #:verify-certificate? #f)) > + > + (let ((port (get-port))) > + (catch #t > + (lambda () > + (proc port)) > + (lambda (key . args) > + ;; If PORT was cached and the server closed the connection in the > + ;; meantime, we get EPIPE. In that case, open a fresh connection > + ;; and retry. We might also get 'bad-response or a similar > + ;; exception from (web response) later on, once we've sent the > + ;; request, or a ERROR/INVALID-SESSION from GnuTLS. > + (if (or (and (eq? key 'system-error) > + (=3D EPIPE (system-error-errno `(,key ,@args)))) > + (and (eq? key 'gnutls-error) > + (eq? (first args) error/invalid-session)) > + (memq key '(bad-response bad-header bad-header-component= ))) > + (begin > + (close-port port) ; close the port to get a fresh one > + (proc (get-port))) I find it marginally clearer to pass #:fresh? #t (as was done in the code removed in 7c85877fdf964694061e3192eac35723ebc047bf) than to rely on the closed-port side effect. I think it=E2=80=99s OK to remove =E2=80=98-and-error-handling=E2=80=99 bec= ause that doesn=E2=80=99t really tell much and because too many words obscure the message IMO, but that=E2=80=99s a detail. I also like the helper macro as was removed in 7c85877fdf964694061e3192eac35723ebc047bf. Apart from that LGTM. My limited testing suggests it=E2=80=99s working as intended. Thank you! Ludo=E2=80=99.