diff --git a/guix/http-client.scm b/guix/http-client.scm index a2e11a1b73..b9cf0b1a4b 100644 --- a/guix/http-client.scm +++ b/guix/http-client.scm @@ -38,7 +38,7 @@ #:use-module (guix utils) #:use-module (guix base64) #:autoload (gcrypt hash) (sha256) - #:autoload (gnutls) (error/invalid-session) + #:autoload (gnutls) (error/invalid-session error/again) #:use-module ((guix build utils) #:select (mkdir-p dump-port)) #:use-module ((guix build download) @@ -163,7 +163,8 @@ reusing stale cached connections." (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 (first args) + (list error/again error/invalid-session))) (memq key '(bad-response bad-header bad-header-component))) #f @@ -207,15 +208,14 @@ returning." ;; Inherit the HTTP proxying property from P. (set-http-proxy-port?! buffer (http-proxy-port? p)) - (unless (false-if-networking-error - (begin - (for-each (cut write-request <> buffer) batch) - (put-bytevector p (get)) - (force-output p) - #t)) - ;; If PORT becomes unusable, open a fresh connection and retry. - (close-port p) ; close the broken port - (connect #f requests result))) + ;; Swallow networking errors that could occur due to connection reuse + ;; and the like; they will be handled down the road when trying to + ;; read responses. + (false-if-networking-error + (begin + (for-each (cut write-request <> buffer) batch) + (put-bytevector p (get)) + (force-output p)))) ;; Now start processing responses. (let loop ((sent batch) diff --git a/guix/scripts/substitute.scm b/guix/scripts/substitute.scm index 48309f9b3a..65940591a9 100755 --- a/guix/scripts/substitute.scm +++ b/guix/scripts/substitute.scm @@ -45,7 +45,7 @@ #:select (uri-abbreviation nar-uri-abbreviation (open-connection-for-uri . guix:open-connection-for-uri))) - #:autoload (gnutls) (error/invalid-session) + #:autoload (gnutls) (error/invalid-session error/again) #:use-module (guix progress) #:use-module ((guix build syscalls) #:select (set-thread-name)) @@ -417,7 +417,8 @@ server certificates." (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 (first args) + (list error/again error/invalid-session))) (memq key '(bad-response bad-header bad-header-component))) (proc (open-connection-for-uri/cached uri #:verify-certificate? #f