]> granicus.if.org Git - libevent/commitdiff
On FreeBSD and other OSes, connect can return ECONREFUSED immediately; instead of...
authorNiels Provos <provos@gmail.com>
Thu, 19 Nov 2009 21:14:31 +0000 (21:14 +0000)
committerNiels Provos <provos@gmail.com>
Thu, 19 Nov 2009 21:14:31 +0000 (21:14 +0000)
svn:r1553

ChangeLog
http.c

index d3c6e4c0f056cc751898ca58ca02447e3da06cfe..be01b27bbf61dabee1432911c4da8495cd5d5499 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -51,7 +51,7 @@ Changes in 2.0.3-alpha:
  o Add an evdns_getaddrinfo() function to provide a nonblocking getaddrinfo using evdns, so programs can perform useful hostname lookup.
  o Finally expose the IOCP-based bufferevent backend.  It passes its unit tests, but probably still has some bugs remaining.  Code by Nick Mathewson and Christopher Davis.
  o Numerous other bugfixes.
-
+ o On FreeBSD and other OSes, connect can return ECONREFUSED immediately; instead of failing the function call, pretend with faileld in the callback.
 
 Changes in 2.0.2-alpha:
  o Add a new flag to bufferevents to make all callbacks automatically deferred.
diff --git a/http.c b/http.c
index 7371677950e48d3fc105310adf8fc9d7c1efb3a3..acbd0b575777ff45d54216bb6cd944594f78e673 100644 (file)
--- a/http.c
+++ b/http.c
@@ -1849,8 +1849,12 @@ evhttp_connection_connect(struct evhttp_connection *evcon)
        if (socket_connect(evcon->fd, evcon->address, evcon->port) == -1) {
                event_sock_warn(evcon->fd, "%s: connection to \"%s\" failed",
                    __func__, evcon->address);
-               EVUTIL_CLOSESOCKET(evcon->fd); evcon->fd = -1;
-               return (-1);
+               /* some operating systems return ECONNREFUSED immediately
+                * when connecting to a local address.  the cleanup is going
+                * to reschedule this function call.
+                */
+               evhttp_connection_cb_cleanup(evcon);
+               return (0);
        }
 
        /* Set up a callback for successful connection setup */