On FreeBSD and other OSes, connect can return ECONREFUSED immediately; instead of failing the function call, pretend with faileld in the callback.

svn:r1553
This commit is contained in:
Niels Provos 2009-11-19 21:14:31 +00:00
parent bdfe72f3c5
commit b8f222e055
2 changed files with 7 additions and 3 deletions

View File

@ -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 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 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 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: Changes in 2.0.2-alpha:
o Add a new flag to bufferevents to make all callbacks automatically deferred. o Add a new flag to bufferevents to make all callbacks automatically deferred.

8
http.c
View File

@ -1849,8 +1849,12 @@ evhttp_connection_connect(struct evhttp_connection *evcon)
if (socket_connect(evcon->fd, evcon->address, evcon->port) == -1) { if (socket_connect(evcon->fd, evcon->address, evcon->port) == -1) {
event_sock_warn(evcon->fd, "%s: connection to \"%s\" failed", event_sock_warn(evcon->fd, "%s: connection to \"%s\" failed",
__func__, evcon->address); __func__, evcon->address);
EVUTIL_CLOSESOCKET(evcon->fd); evcon->fd = -1; /* some operating systems return ECONNREFUSED immediately
return (-1); * 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 */ /* Set up a callback for successful connection setup */