[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.7-10-gb9d724

From: Ludovic Courtès
Subject: [Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.7-10-gb9d7249
Date: Sun, 16 Dec 2012 23:28:09 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".

The branch, stable-2.0 has been updated
       via  b9d724982d01899ca09b02f889e7207e06a43803 (commit)
      from  21982d68ab11580cbe35dee2f98334e09545fd93 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit b9d724982d01899ca09b02f889e7207e06a43803
Author: Ludovic Courtès <address@hidden>
Date:   Mon Dec 17 00:27:00 2012 +0100

    web: Correctly detect "No route to host" conditions.
    * module/web/client.scm (open-socket-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 <address@hidden> at


Summary of changes:
 module/web/client.scm |   25 ++++++++++++++-----------
 1 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/module/web/client.scm b/module/web/client.scm
index df0a749..6aedb75 100644
--- a/module/web/client.scm
+++ b/module/web/client.scm
@@ -38,6 +38,7 @@
   #:use-module (web request)
   #:use-module (web response)
   #:use-module (web uri)
+  #:use-module (srfi srfi-1)
   #:export (open-socket-for-uri
@@ -46,19 +47,21 @@
   "Return an open input/output port for a connection to URI."
   (define addresses
     (let ((port (uri-port uri)))
-      (getaddrinfo (uri-host uri)
-                   (cond (port => number->string)
-                         (else (symbol->string (uri-scheme uri))))
-                   (if port
-                       AI_NUMERICSERV
-                       0))))
+      (delete-duplicates
+       (getaddrinfo (uri-host uri)
+                    (cond (port => number->string)
+                          (else (symbol->string (uri-scheme uri))))
+                    (if port
+                        AI_NUMERICSERV
+                        0))
+       (lambda (ai1 ai2)
+         (equal? (addrinfo:addr ai1) (addrinfo:addr ai2))))))
   (let loop ((addresses addresses))
     (let* ((ai (car addresses))
-           (s  (socket (addrinfo:fam ai) (addrinfo:socktype ai)
-                       (addrinfo:protocol ai))))
-      (set-port-encoding! s "ISO-8859-1")
+           (s  (with-fluids ((%default-port-encoding #f))
+                 ;; Restrict ourselves to TCP.
+                 (socket (addrinfo:fam ai) SOCK_STREAM IPPROTO_IP))))
       (catch 'system-error
         (lambda ()
           (connect s (addrinfo:addr ai))
@@ -71,7 +74,7 @@
         (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))))))))

GNU Guile

reply via email to

[Prev in Thread] Current Thread [Next in Thread]