X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libtest%2Fdns.cc;h=0becfc99107f22068e22d512ab9cc2e971989754;hb=b30da3e793829246675966830c668c3f60496e07;hp=a293caa3b4319a83cf43a8adb734f7835dc2bb12;hpb=ad5cb8f903869065c72bb18bf98af6909189a5a9;p=m6w6%2Flibmemcached diff --git a/libtest/dns.cc b/libtest/dns.cc index a293caa3..0becfc99 100644 --- a/libtest/dns.cc +++ b/libtest/dns.cc @@ -34,7 +34,7 @@ * */ -#include "mem_config.h" +#include "libtest/yatlcon.h" #include #include @@ -45,16 +45,28 @@ namespace libtest { bool lookup(const char* host) { - assert(host); bool success= false; - struct addrinfo *addrinfo= NULL; - - int limit= 5; - while (limit--) + if (host) { - int ret; - if ((ret= getaddrinfo(host, NULL, NULL, &(addrinfo)))) + assert(host); + struct addrinfo *addrinfo= NULL; + + int limit= 5; + while (--limit and success == false) { + if (addrinfo) + { + freeaddrinfo(addrinfo); + addrinfo= NULL; + } + + int ret; + if ((ret= getaddrinfo(host, NULL, NULL, &addrinfo)) == 0) + { + success= true; + break; + } + switch (ret) { case EAI_AGAIN: @@ -64,16 +76,16 @@ bool lookup(const char* host) default: break; } + + break; } - else + + if (addrinfo) { - success= true; - break; + freeaddrinfo(addrinfo); } } - freeaddrinfo(addrinfo); - return success; } @@ -87,7 +99,7 @@ bool check_dns() if (lookup("does_not_exist.gearman.info")) // This should fail, if it passes,... { - return false; + fatal_assert("Your service provider sucks and is providing bogus DNS. You might be in an airport."); } return true;