all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: Christopher Baines <mail@cbaines.net>
Cc: 47160@debbugs.gnu.org
Subject: [bug#47160] [PATCH] scripts: substitute: Add back some error handling.
Date: Tue, 16 Mar 2021 22:30:19 +0100	[thread overview]
Message-ID: <87k0q67pn8.fsf_-_@gnu.org> (raw)
In-Reply-To: <20210315161532.1716-1-mail@cbaines.net> (Christopher Baines's message of "Mon, 15 Mar 2021 16:15:31 +0000")

Christopher Baines <mail@cbaines.net> skribis:

> In f50f5751fff4cfc6d5abba9681054569694b7a5c, the way fetch was called within
> process-substitution was changed.  As with-cached-connection actually includes
> 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
“Fixes <https://bugs.gnu.org/47157>.” 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)
> +                     (= 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’s OK to remove ‘-and-error-handling’ because that doesn’t
really tell much and because too many words obscure the message IMO, but
that’s a detail.  I also like the helper macro as was removed in
7c85877fdf964694061e3192eac35723ebc047bf.

Apart from that LGTM.

My limited testing suggests it’s working as intended.

Thank you!

Ludo’.




  parent reply	other threads:[~2021-03-16 21:38 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-15 15:11 [bug#47160] [PATCH] scripts: substitute: Add back some error handling Christopher Baines
2021-03-15 15:20 ` Ludovic Courtès
2021-03-15 16:15   ` Christopher Baines
2021-03-15 20:51     ` Ludovic Courtès
2021-03-15 21:33       ` Christopher Baines
2021-03-16 20:34         ` Ludovic Courtès
2021-03-15 16:15 ` [bug#47160] [PATCH v2 1/2] " Christopher Baines
2021-03-15 16:15   ` [bug#47160] [PATCH v2 2/2] scripts: substitute: Tweak error reporting in process-substitution Christopher Baines
2021-03-16 21:30   ` Ludovic Courtès [this message]
2021-03-16 23:11     ` [bug#47160] [PATCH] scripts: substitute: Add back some error handling Christopher Baines
2021-03-16 23:46 ` [bug#47160] [PATCH 1/2] " Christopher Baines
2021-03-16 23:46   ` [bug#47160] [PATCH 2/2] scripts: substitute: Tweak error reporting in process-substitution Christopher Baines
2021-03-17 20:18   ` [bug#47160] [PATCH] scripts: substitute: Add back some error handling Ludovic Courtès
2021-03-17 20:46     ` bug#47160: " Christopher Baines

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k0q67pn8.fsf_-_@gnu.org \
    --to=ludo@gnu.org \
    --cc=47160@debbugs.gnu.org \
    --cc=mail@cbaines.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.