diff options
author | Mukund Sivaraman <muks@banu.com> | 2010-03-09 17:08:37 +0530 |
---|---|---|
committer | Mukund Sivaraman <muks@banu.com> | 2010-03-09 17:08:37 +0530 |
commit | d37a6b2c122bfac52d1c1067f9c3ba6212c4c0ef (patch) | |
tree | e44b20e7e3b59e24957bd5435ae30e8fe8ff9cf6 /src | |
parent | 2f86b79d8541c099d8a7510d6c31d09b53153b97 (diff) | |
download | tinyproxy-d37a6b2c122bfac52d1c1067f9c3ba6212c4c0ef.tar.gz tinyproxy-d37a6b2c122bfac52d1c1067f9c3ba6212c4c0ef.zip |
Revert "Revert "Pass address family when binding to outgoing socket""
This reverts commit 70885bf029a6f857684f99618f867b5c47767ae0. It looks
like bug #69 needs this fix after all.
Diffstat (limited to '')
-rw-r--r-- | src/sock.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -39,7 +39,8 @@ * returned if the bind succeeded. Otherwise, -1 is returned * to indicate an error. */ -static int bind_socket (int sockfd, const char *addr) +static int +bind_socket (int sockfd, const char *addr, int family) { struct addrinfo hints, *res, *ressave; @@ -47,7 +48,7 @@ static int bind_socket (int sockfd, const char *addr) assert (addr != NULL && strlen (addr) != 0); memset (&hints, 0, sizeof (struct addrinfo)); - hints.ai_family = AF_UNSPEC; + hints.ai_family = family; hints.ai_socktype = SOCK_STREAM; /* The local port it not important */ @@ -105,12 +106,14 @@ int opensock (const char *host, int port, const char *bind_to) /* Bind to the specified address */ if (bind_to) { - if (bind_socket (sockfd, bind_to) < 0) { + if (bind_socket (sockfd, bind_to, + res->ai_family) < 0) { close (sockfd); continue; /* can't bind, so try again */ } } else if (config.bind_address) { - if (bind_socket (sockfd, config.bind_address) < 0) { + if (bind_socket (sockfd, config.bind_address, + res->ai_family) < 0) { close (sockfd); continue; /* can't bind, so try again */ } |