Fix mysterious 1 second delay with async DNS

pull/538/head
Tatsuhiro Tsujikawa 2016-01-19 10:42:25 +09:00
parent e6b6aa324b
commit ffec92ec57
2 changed files with 36 additions and 38 deletions

View File

@ -170,9 +170,8 @@ int DHTEntryPointNameResolveCommand::resolveHostname(
{ {
if (!asyncNameResolverMan_->started()) { if (!asyncNameResolverMan_->started()) {
asyncNameResolverMan_->startAsync(hostname, e_, this); asyncNameResolverMan_->startAsync(hostname, e_, this);
return 0;
} }
else {
switch (asyncNameResolverMan_->getStatus()) { switch (asyncNameResolverMan_->getStatus()) {
case -1: case -1:
A2_LOG_INFO(fmt(MSG_NAME_RESOLUTION_FAILED, getCuid(), hostname.c_str(), A2_LOG_INFO(fmt(MSG_NAME_RESOLUTION_FAILED, getCuid(), hostname.c_str(),
@ -188,12 +187,12 @@ int DHTEntryPointNameResolveCommand::resolveHostname(
return -1; return -1;
} }
else { else {
A2_LOG_INFO(fmt(MSG_NAME_RESOLUTION_COMPLETE, getCuid(), A2_LOG_INFO(fmt(MSG_NAME_RESOLUTION_COMPLETE, getCuid(), hostname.c_str(),
hostname.c_str(), res.front().c_str())); res.front().c_str()));
return 1; return 1;
} }
} }
}
// Unreachable // Unreachable
return 0; return 0;
} }

View File

@ -148,9 +148,8 @@ int NameResolveCommand::resolveHostname(std::vector<std::string>& res,
{ {
if (!asyncNameResolverMan_->started()) { if (!asyncNameResolverMan_->started()) {
asyncNameResolverMan_->startAsync(hostname, e_, this); asyncNameResolverMan_->startAsync(hostname, e_, this);
return 0;
} }
else {
switch (asyncNameResolverMan_->getStatus()) { switch (asyncNameResolverMan_->getStatus()) {
case -1: case -1:
A2_LOG_INFO(fmt(MSG_NAME_RESOLUTION_FAILED, getCuid(), hostname.c_str(), A2_LOG_INFO(fmt(MSG_NAME_RESOLUTION_FAILED, getCuid(), hostname.c_str(),
@ -166,12 +165,12 @@ int NameResolveCommand::resolveHostname(std::vector<std::string>& res,
return -1; return -1;
} }
else { else {
A2_LOG_INFO(fmt(MSG_NAME_RESOLUTION_COMPLETE, getCuid(), A2_LOG_INFO(fmt(MSG_NAME_RESOLUTION_COMPLETE, getCuid(), hostname.c_str(),
hostname.c_str(), res.front().c_str())); res.front().c_str()));
return 1; return 1;
} }
} }
}
// Unreachable // Unreachable
return 0; return 0;
} }