Merge pull request #858 from nghttp2/nghttpx-ai-addrconfig

nghttpx: Retry getaddrinfo without AI_ADDRCONFIG
This commit is contained in:
Tatsuhiro Tsujikawa 2017-03-27 22:37:07 +09:00 committed by GitHub
commit 041531458b
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; addrinfo *res, *rp;
rv = getaddrinfo(node, service.c_str(), &hints, &res); 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) { if (rv != 0) {
LOG(FATAL) << "Unable to get IPv" << (faddr.family == AF_INET ? "4" : "6") LOG(FATAL) << "Unable to get IPv" << (faddr.family == AF_INET ? "4" : "6")
<< " address for " << faddr.host << ", port " << faddr.port << " 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; addrinfo *res;
rv = getaddrinfo(hostname, service.c_str(), &hints, &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) { if (rv != 0) {
LOG(FATAL) << "Unable to resolve address for " << hostname << ": " LOG(FATAL) << "Unable to resolve address for " << hostname << ": "
<< gai_strerror(rv); << gai_strerror(rv);