diff options
author | Ludovic Courtès <ludo@gnu.org> | 2012-12-17 00:14:30 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2012-12-17 00:14:30 +0100 |
commit | 3c738d6bd879aa884be0e40e631a36570e8f0d03 (patch) | |
tree | a17f268f082dcf061b05eeef139bd84a1d572c87 | |
parent | 868fce7c4ae92d533ec6936c8077cd4845aebd19 (diff) | |
download | guix-3c738d6bd879aa884be0e40e631a36570e8f0d03.tar.gz guix-3c738d6bd879aa884be0e40e631a36570e8f0d03.zip |
download: Correctly detect "No route to host" conditions.
* guix/build/download.scm (open-connection-for-uri): Delete addrinfos
with the same address. Always open SOCK_STREAM/IPPROTO_IP sockets.
Fix the error handler's condition to determine what to do.
Reported by Nikita Karetnikov <nikita.karetnikov@gmail.com> at
<http://lists.gnu.org/archive/html/bug-guix/2012-12/msg00150.html>.
-rw-r--r-- | guix/build/download.scm | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/guix/build/download.scm b/guix/build/download.scm index c09351cee4..074315cc9f 100644 --- a/guix/build/download.scm +++ b/guix/build/download.scm @@ -60,15 +60,18 @@ which is not available during bootstrap." ((http) 80) ; /etc/services, not for me! (else (error "unsupported URI scheme" uri)))))) - (getaddrinfo (uri-host uri) - (number->string port) - AI_NUMERICSERV))) + (delete-duplicates (getaddrinfo (uri-host uri) + (number->string port) + AI_NUMERICSERV) + (lambda (ai1 ai2) + (equal? (addrinfo:addr ai1) + (addrinfo:addr ai2)))))) (let loop ((addresses addresses)) (let* ((ai (car addresses)) (s (with-fluids ((%default-port-encoding #f)) - (socket (addrinfo:fam ai) (addrinfo:socktype ai) - (addrinfo:protocol ai))))) + ;; Restrict ourselves to TCP. + (socket (addrinfo:fam ai) SOCK_STREAM IPPROTO_IP)))) (catch 'system-error (lambda () (connect s (addrinfo:addr ai)) @@ -81,7 +84,7 @@ which is not available during bootstrap." (lambda args ;; Connection failed, so try one of the other addresses. (close s) - (if (null? addresses) + (if (null? (cdr addresses)) (apply throw args) (loop (cdr addresses)))))))) |