Revert "Pass address family when binding to outgoing socket"
authorMukund Sivaraman <muks@banu.com>
Thu, 21 Jan 2010 00:59:15 +0000 (06:29 +0530)
committerMukund Sivaraman <muks@banu.com>
Thu, 21 Jan 2010 00:59:15 +0000 (06:29 +0530)
This reverts commit 65ef313cc4601b5ad84d1da1800ff38bf8f046a9.
This patch could've been the reason for BB#69.

src/sock.c

index f7ddd7492b108409da961a198a987e94368e796c..bf32c78fefc9db4c92b368c7325143a6cf59b9c9 100644 (file)
@@ -39,8 +39,7 @@
  * returned if the bind succeeded.  Otherwise, -1 is returned
  * to indicate an error.
  */
-static int
-bind_socket (int sockfd, const char *addr, int family)
+static int bind_socket (int sockfd, const char *addr)
 {
         struct addrinfo hints, *res, *ressave;
 
@@ -48,7 +47,7 @@ bind_socket (int sockfd, const char *addr, int family)
         assert (addr != NULL && strlen (addr) != 0);
 
         memset (&hints, 0, sizeof (struct addrinfo));
-        hints.ai_family = family;
+        hints.ai_family = AF_UNSPEC;
         hints.ai_socktype = SOCK_STREAM;
 
         /* The local port it not important */
@@ -106,14 +105,12 @@ 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,
-                                         res->ai_family) < 0) {
+                        if (bind_socket (sockfd, bind_to) < 0) {
                                 close (sockfd);
                                 continue;       /* can't bind, so try again */
                         }
                 } else if (config.bind_address) {
-                        if (bind_socket (sockfd, config.bind_address,
-                                         res->ai_family) < 0) {
+                        if (bind_socket (sockfd, config.bind_address) < 0) {
                                 close (sockfd);
                                 continue;       /* can't bind, so try again */
                         }