Lines 90-100
checkProtocols(bool *hasIPv4, bool *hasIPv6,
Link Here
|
90 |
if ((s4 = socket(AF_INET, SOCK_STREAM, 0)) < 0) |
90 |
if ((s4 = socket(AF_INET, SOCK_STREAM, 0)) < 0) |
91 |
goto cleanup; |
91 |
goto cleanup; |
92 |
|
92 |
|
93 |
if ((s6 = socket(AF_INET6, SOCK_STREAM, 0)) < 0) |
93 |
if (*hasIPv6) { |
94 |
goto cleanup; |
94 |
if ((s6 = socket(AF_INET6, SOCK_STREAM, 0)) < 0) |
|
|
95 |
goto cleanup; |
95 |
|
96 |
|
96 |
if (setsockopt(s6, IPPROTO_IPV6, IPV6_V6ONLY, &only, sizeof(only)) < 0) |
97 |
if (setsockopt(s6, IPPROTO_IPV6, IPV6_V6ONLY, &only, sizeof(only)) < 0) |
97 |
goto cleanup; |
98 |
goto cleanup; |
|
|
99 |
} |
98 |
|
100 |
|
99 |
memset(&in4, 0, sizeof(in4)); |
101 |
memset(&in4, 0, sizeof(in4)); |
100 |
memset(&in6, 0, sizeof(in6)); |
102 |
memset(&in6, 0, sizeof(in6)); |
Lines 114-126
checkProtocols(bool *hasIPv4, bool *hasIPv6,
Link Here
|
114 |
} |
116 |
} |
115 |
goto cleanup; |
117 |
goto cleanup; |
116 |
} |
118 |
} |
117 |
if (bind(s6, (struct sockaddr *)&in6, sizeof(in6)) < 0) { |
119 |
|
118 |
if (errno == EADDRINUSE) { |
120 |
if (*hasIPv6) { |
119 |
VIR_FORCE_CLOSE(s4); |
121 |
if (bind(s6, (struct sockaddr *)&in6, sizeof(in6)) < 0) { |
120 |
VIR_FORCE_CLOSE(s6); |
122 |
if (errno == EADDRINUSE) { |
121 |
continue; |
123 |
VIR_FORCE_CLOSE(s4); |
|
|
124 |
VIR_FORCE_CLOSE(s6); |
125 |
continue; |
126 |
} |
127 |
goto cleanup; |
122 |
} |
128 |
} |
123 |
goto cleanup; |
|
|
124 |
} |
129 |
} |
125 |
|
130 |
|
126 |
*freePort = BASE_PORT + i; |
131 |
*freePort = BASE_PORT + i; |