120-fix_INET6.patch 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. --- a/src/sock.c
  2. +++ b/src/sock.c
  3. @@ -39,8 +39,7 @@
  4. * returned if the bind succeeded. Otherwise, -1 is returned
  5. * to indicate an error.
  6. */
  7. -static int
  8. -bind_socket (int sockfd, const char *addr, int family)
  9. +static int bind_socket (int sockfd, const char *addr)
  10. {
  11. struct addrinfo hints, *res, *ressave;
  12. @@ -48,7 +47,7 @@ bind_socket (int sockfd, const char *add
  13. assert (addr != NULL && strlen (addr) != 0);
  14. memset (&hints, 0, sizeof (struct addrinfo));
  15. - hints.ai_family = family;
  16. + hints.ai_family = AF_UNSPEC;
  17. hints.ai_socktype = SOCK_STREAM;
  18. /* The local port it not important */
  19. @@ -106,14 +105,12 @@ int opensock (const char *host, int port
  20. /* Bind to the specified address */
  21. if (bind_to) {
  22. - if (bind_socket (sockfd, bind_to,
  23. - res->ai_family) < 0) {
  24. + if (bind_socket (sockfd, bind_to) < 0) {
  25. close (sockfd);
  26. continue; /* can't bind, so try again */
  27. }
  28. } else if (config.bind_address) {
  29. - if (bind_socket (sockfd, config.bind_address,
  30. - res->ai_family) < 0) {
  31. + if (bind_socket (sockfd, config.bind_address) < 0) {
  32. close (sockfd);
  33. continue; /* can't bind, so try again */
  34. }