mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-13 06:16:10 -04:00
only bind the socket on connect when a local address has been provided; reported by Ajejo Sanchez
svn:r946
This commit is contained in:
parent
31cfe52662
commit
50202d757d
@ -126,6 +126,7 @@ Changes in current version:
|
||||
o Add new utility functions to correctly observe and log winsock errors.
|
||||
o Do not remove Accept-Encoding header
|
||||
o Clear the timer cache on entering the event loop; reported by Victor Chang
|
||||
o Only bind the socket on connect when a local address has been provided; reported by Alejo Sanchez
|
||||
|
||||
Changes in 1.4.0:
|
||||
o allow \r or \n individually to separate HTTP headers instead of the standard "\r\n"; from Charles Kerr.
|
||||
|
20
http.c
20
http.c
@ -2846,8 +2846,8 @@ name_from_addr(struct sockaddr *sa, socklen_t salen,
|
||||
*pport = mm_strdup(strport);
|
||||
}
|
||||
|
||||
/* Either connect or bind */
|
||||
|
||||
/* Create a non-blocking socket and bind it */
|
||||
/* todo: rename this function */
|
||||
static evutil_socket_t
|
||||
bind_socket_ai(struct addrinfo *ai, int reuse)
|
||||
{
|
||||
@ -2879,9 +2879,11 @@ bind_socket_ai(struct addrinfo *ai, int reuse)
|
||||
(void *)&on, sizeof(on));
|
||||
}
|
||||
|
||||
r = bind(fd, ai->ai_addr, ai->ai_addrlen);
|
||||
if (r == -1)
|
||||
goto out;
|
||||
if (ai != NULL) {
|
||||
r = bind(fd, ai->ai_addr, ai->ai_addrlen);
|
||||
if (r == -1)
|
||||
goto out;
|
||||
}
|
||||
|
||||
return (fd);
|
||||
|
||||
@ -2934,7 +2936,13 @@ static evutil_socket_t
|
||||
bind_socket(const char *address, ev_uint16_t port, int reuse)
|
||||
{
|
||||
evutil_socket_t fd;
|
||||
struct addrinfo *aitop = make_addrinfo(address, port);
|
||||
struct addrinfo *aitop = NULL;
|
||||
|
||||
/* just create an unbound socket */
|
||||
if (address == NULL && port == 0)
|
||||
return bind_socket_ai(NULL, 0);
|
||||
|
||||
aitop = make_addrinfo(address, port);
|
||||
|
||||
if (aitop == NULL)
|
||||
return (-1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user