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:
default:
break;
}
+
+ break;
}
- else
+
+ if (addrinfo)
{
- success= true;
- break;
+ freeaddrinfo(addrinfo);
}
}
- freeaddrinfo(addrinfo);
-
return success;
}
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;