summary refs log tree commit diff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2013-11-14 01:09:07 +0100
committerLudovic Courtès <ludo@gnu.org>2013-11-14 01:09:07 +0100
commitc509bf8c87140ccb4d5f0709c4de8905819b90ad (patch)
treef38a79ca66188f76ba3bf5ed9c9198505c261047
parenta716e36de915a275e4eab42b73cf0a2affc4aa33 (diff)
downloadguix-c509bf8c87140ccb4d5f0709c4de8905819b90ad.tar.gz
substitute-binary: Adjust timeout handling for Guile > 2.0.9.
* guix/scripts/substitute-binary.scm (with-timeout): Update comment to
  mention the fix's commit ID.
  (fetch): In the 'with-timeout' handler, close PORT only one Guile
  versions < 2.0.9.39.  Before that, on Guile >= 2.0.9.39, the HTTP
  client would end up trying to read from a closed file descriptor.
-rwxr-xr-xguix/scripts/substitute-binary.scm16
1 files changed, 12 insertions, 4 deletions
diff --git a/guix/scripts/substitute-binary.scm b/guix/scripts/substitute-binary.scm
index 44699cfca9..83e3d25dba 100755
--- a/guix/scripts/substitute-binary.scm
+++ b/guix/scripts/substitute-binary.scm
@@ -123,7 +123,8 @@ again."
               (lambda ()
                 body ...)
               (lambda args
-                ;; The SIGALRM triggers EINTR, because of the bug at
+                ;; Before Guile v2.0.9-39-gfe51c7b, the SIGALRM triggers EINTR
+                ;; because of the bug at
                 ;; <http://lists.gnu.org/archive/html/guile-devel/2013-06/msg00050.html>.
                 ;; When that happens, try again.  Note: SA_RESTART cannot be
                 ;; used because of <http://bugs.gnu.org/14640>.
@@ -162,10 +163,17 @@ provide."
            (warning (_ "while fetching ~a: server is unresponsive~%")
                     (uri->string uri))
            (warning (_ "try `--no-substitutes' if the problem persists~%"))
-           (when port
-             (close-port port)))
+
+           ;; Before Guile v2.0.9-39-gfe51c7b, EINTR was reported to the user,
+           ;; and thus PORT had to be closed and re-opened.  This is not the
+           ;; case afterward.
+           (unless (or (guile-version>? "2.0.9")
+                       (version>? (version) "2.0.9.39"))
+             (when port
+               (close-port port))))
          (begin
-           (set! port (open-socket-for-uri uri #:buffered? buffered?))
+           (when (or (not port) (port-closed? port))
+             (set! port (open-socket-for-uri uri #:buffered? buffered?)))
            (http-fetch uri #:text? #f #:port port)))))))
 
 (define-record-type <cache>