mirror of
https://github.com/SChernykh/p2pool.git
synced 2024-12-23 03:49:23 +00:00
Retry getaddrinfo
with IPv4 only after an error
This commit is contained in:
parent
8876af53d8
commit
c7ba11c607
2 changed files with 12 additions and 2 deletions
|
@ -497,7 +497,12 @@ void P2PServer::load_peer_list()
|
|||
hints.ai_flags = AI_ADDRCONFIG;
|
||||
|
||||
addrinfo* result;
|
||||
const int err = getaddrinfo(nodes[i], nullptr, &hints, &result);
|
||||
int err = getaddrinfo(nodes[i], nullptr, &hints, &result);
|
||||
if (err) {
|
||||
LOGWARN(4, "getaddrinfo failed for " << nodes[i] << ": " << gai_strerror(err) << ", retrying with IPv4 only");
|
||||
hints.ai_family = AF_INET;
|
||||
err = getaddrinfo(nodes[i], nullptr, &hints, &result);
|
||||
}
|
||||
if (err == 0) {
|
||||
for (addrinfo* r = result; r != NULL; r = r->ai_next) {
|
||||
const char* addr_str;
|
||||
|
|
|
@ -420,7 +420,12 @@ bool resolve_host(std::string& host, bool& is_v6)
|
|||
hints.ai_flags = AI_ADDRCONFIG;
|
||||
|
||||
addrinfo* r = nullptr;
|
||||
const int err = getaddrinfo(host.c_str(), nullptr, &hints, &r);
|
||||
int err = getaddrinfo(host.c_str(), nullptr, &hints, &r);
|
||||
if (err) {
|
||||
LOGWARN(4, "getaddrinfo failed for " << host << ": " << gai_strerror(err) << ", retrying with IPv4 only");
|
||||
hints.ai_family = AF_INET;
|
||||
err = getaddrinfo(host.c_str(), nullptr, &hints, &r);
|
||||
}
|
||||
if ((err == 0) && r) {
|
||||
const char* addr_str = nullptr;
|
||||
char addr_str_buf[64];
|
||||
|
|
Loading…
Reference in a new issue