mirror of https://github.com/aria2/aria2
Fix mysterious 1 second delay with async DNS
parent
e6b6aa324b
commit
ffec92ec57
|
@ -170,30 +170,29 @@ int DHTEntryPointNameResolveCommand::resolveHostname(
|
|||
{
|
||||
if (!asyncNameResolverMan_->started()) {
|
||||
asyncNameResolverMan_->startAsync(hostname, e_, this);
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
switch (asyncNameResolverMan_->getStatus()) {
|
||||
case -1:
|
||||
|
||||
switch (asyncNameResolverMan_->getStatus()) {
|
||||
case -1:
|
||||
A2_LOG_INFO(fmt(MSG_NAME_RESOLUTION_FAILED, getCuid(), hostname.c_str(),
|
||||
asyncNameResolverMan_->getLastError().c_str()));
|
||||
return -1;
|
||||
case 0:
|
||||
return 0;
|
||||
case 1:
|
||||
asyncNameResolverMan_->getResolvedAddress(res);
|
||||
if (res.empty()) {
|
||||
A2_LOG_INFO(fmt(MSG_NAME_RESOLUTION_FAILED, getCuid(), hostname.c_str(),
|
||||
asyncNameResolverMan_->getLastError().c_str()));
|
||||
"No address returned"));
|
||||
return -1;
|
||||
case 0:
|
||||
return 0;
|
||||
case 1:
|
||||
asyncNameResolverMan_->getResolvedAddress(res);
|
||||
if (res.empty()) {
|
||||
A2_LOG_INFO(fmt(MSG_NAME_RESOLUTION_FAILED, getCuid(), hostname.c_str(),
|
||||
"No address returned"));
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
A2_LOG_INFO(fmt(MSG_NAME_RESOLUTION_COMPLETE, getCuid(),
|
||||
hostname.c_str(), res.front().c_str()));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
A2_LOG_INFO(fmt(MSG_NAME_RESOLUTION_COMPLETE, getCuid(), hostname.c_str(),
|
||||
res.front().c_str()));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Unreachable
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -148,30 +148,29 @@ int NameResolveCommand::resolveHostname(std::vector<std::string>& res,
|
|||
{
|
||||
if (!asyncNameResolverMan_->started()) {
|
||||
asyncNameResolverMan_->startAsync(hostname, e_, this);
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
switch (asyncNameResolverMan_->getStatus()) {
|
||||
case -1:
|
||||
|
||||
switch (asyncNameResolverMan_->getStatus()) {
|
||||
case -1:
|
||||
A2_LOG_INFO(fmt(MSG_NAME_RESOLUTION_FAILED, getCuid(), hostname.c_str(),
|
||||
asyncNameResolverMan_->getLastError().c_str()));
|
||||
return -1;
|
||||
case 0:
|
||||
return 0;
|
||||
case 1:
|
||||
asyncNameResolverMan_->getResolvedAddress(res);
|
||||
if (res.empty()) {
|
||||
A2_LOG_INFO(fmt(MSG_NAME_RESOLUTION_FAILED, getCuid(), hostname.c_str(),
|
||||
asyncNameResolverMan_->getLastError().c_str()));
|
||||
"No address returned"));
|
||||
return -1;
|
||||
case 0:
|
||||
return 0;
|
||||
case 1:
|
||||
asyncNameResolverMan_->getResolvedAddress(res);
|
||||
if (res.empty()) {
|
||||
A2_LOG_INFO(fmt(MSG_NAME_RESOLUTION_FAILED, getCuid(), hostname.c_str(),
|
||||
"No address returned"));
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
A2_LOG_INFO(fmt(MSG_NAME_RESOLUTION_COMPLETE, getCuid(),
|
||||
hostname.c_str(), res.front().c_str()));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
A2_LOG_INFO(fmt(MSG_NAME_RESOLUTION_COMPLETE, getCuid(), hostname.c_str(),
|
||||
res.front().c_str()));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Unreachable
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue