nghttpx: Retry getaddrinfo without AI_ADDRCONFIG

This commit is contained in:
Tatsuhiro Tsujikawa 2017-03-26 19:35:14 +09:00
parent 7dc39b1ee9
commit f41ac103d3
2 changed files with 14 additions and 0 deletions

View File

@ -715,6 +715,13 @@ int create_tcp_server_socket(UpstreamAddr &faddr,
addrinfo *res, *rp;
rv = getaddrinfo(node, service.c_str(), &hints, &res);
#ifdef AI_ADDRCONFIG
if (rv != 0) {
// Retry without AI_ADDRCONFIG
hints.ai_flags &= ~AI_ADDRCONFIG;
rv = getaddrinfo(node, service.c_str(), &hints, &res);
}
#endif // AI_ADDRCONFIG
if (rv != 0) {
LOG(FATAL) << "Unable to get IPv" << (faddr.family == AF_INET ? "4" : "6")
<< " address for " << faddr.host << ", port " << faddr.port

View File

@ -3761,6 +3761,13 @@ int resolve_hostname(Address *addr, const char *hostname, uint16_t port,
addrinfo *res;
rv = getaddrinfo(hostname, service.c_str(), &hints, &res);
#ifdef AI_ADDRCONFIG
if (rv != 0) {
// Retry without AI_ADDRCONFIG
hints.ai_flags &= ~AI_ADDRCONFIG;
rv = getaddrinfo(hostname, service.c_str(), &hints, &res);
}
#endif // AI_ADDRCONFIG
if (rv != 0) {
LOG(FATAL) << "Unable to resolve address for " << hostname << ": "
<< gai_strerror(rv);