Merge pull request #20731 from pprindeville/isc-dhcp-update-4.4.3-P1
[feed/packages.git] / net / tinyproxy / patches / 120-fix_INET6.patch
1 --- a/src/sock.c
2 +++ b/src/sock.c
3 @@ -63,7 +63,7 @@ static const char * family_string (int a
4 * to indicate an error.
5 */
6 static int
7 -bind_socket (int sockfd, const char *addr, int family)
8 +bind_socket (int sockfd, const char *addr)
9 {
10 struct addrinfo hints, *res, *ressave;
11 int n;
12 @@ -72,14 +72,14 @@ bind_socket (int sockfd, const char *add
13 assert (addr != NULL && strlen (addr) != 0);
14
15 memset (&hints, 0, sizeof (struct addrinfo));
16 - hints.ai_family = family;
17 + hints.ai_family = AF_UNSPEC;
18 hints.ai_socktype = SOCK_STREAM;
19
20 /* The local port is not important */
21 n = getaddrinfo (addr, NULL, &hints, &res);
22 if (n != 0) {
23 log_message (LOG_INFO,
24 - "bind_socket: getaddrinfo failed for %s: %s (af: %s)", addr, get_gai_error (n), family_string(family));
25 + "bind_socket: getaddrinfo failed for %s: %s", addr, get_gai_error (n));
26 return -1;
27 }
28
29 @@ -102,14 +102,14 @@ bind_socket (int sockfd, const char *add
30 * Try binding the given socket to supplied addresses, stopping when one succeeds.
31 */
32 static int
33 -bind_socket_list (int sockfd, sblist *addresses, int family)
34 +bind_socket_list (int sockfd, sblist *addresses)
35 {
36 size_t nb_addresses = sblist_getsize(addresses);
37 size_t i;
38
39 for (i = 0; i < nb_addresses; i++) {
40 const char *address = *(const char **)sblist_get(addresses, i);
41 - if (bind_socket(sockfd, address, family) >= 0) {
42 + if (bind_socket(sockfd, address) >= 0) {
43 log_message(LOG_INFO, "Bound to %s", address);
44 return 0;
45 }
46 @@ -170,14 +170,12 @@ int opensock (const char *host, int port
47
48 /* Bind to the specified address */
49 if (bind_to) {
50 - if (bind_socket (sockfd, bind_to,
51 - res->ai_family) < 0) {
52 + if (bind_socket (sockfd, bind_to) < 0) {
53 close (sockfd);
54 continue; /* can't bind, so try again */
55 }
56 } else if (config->bind_addrs) {
57 - if (bind_socket_list (sockfd, config->bind_addrs,
58 - res->ai_family) < 0) {
59 + if (bind_socket_list (sockfd, config->bind_addrs) < 0) {
60 close (sockfd);
61 continue; /* can't bind, so try again */
62 }