Commit 49b70b22 authored by mef@chromium.org's avatar mef@chromium.org

HostResolverImpl will return ERR_NAME_NOT_RESOLVED instead of Ok if address list is empty

BUG=224248

TEST=net_unittests --gtest_filter=HostResolverImplTest.EmptyListMeansNameNotResolved
NOTRY=true

Review URL: https://chromiumcodereview.appspot.com/14760008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@198799 0039d316-1c4b-4281-b951-d872f2087c98
parent 38c96026
......@@ -682,7 +682,11 @@ class HostResolverImpl::ProcTask
int error,
const int os_error) {
DCHECK(origin_loop_->BelongsToCurrentThread());
DCHECK(error || !results.empty());
// If results are empty, we should return an error.
bool empty_list_on_ok = (error == OK && results.empty());
UMA_HISTOGRAM_BOOLEAN("DNS.EmptyAddressListAndNoError", empty_list_on_ok);
if (empty_list_on_ok)
error = ERR_NAME_NOT_RESOLVED;
bool was_retry_attempt = attempt_number > 1;
......
......@@ -531,6 +531,17 @@ TEST_F(HostResolverImplTest, AsynchronousLookup) {
EXPECT_EQ("just.testing", proc_->GetCaptureList()[0].hostname);
}
TEST_F(HostResolverImplTest, EmptyListMeansNameNotResolved) {
proc_->AddRuleForAllFamilies("just.testing", "");
proc_->SignalMultiple(1u);
Request* req = CreateRequest("just.testing", 80);
EXPECT_EQ(ERR_IO_PENDING, req->Resolve());
EXPECT_EQ(ERR_NAME_NOT_RESOLVED, req->WaitForResult());
EXPECT_EQ(0u, req->NumberOfAddresses());
EXPECT_EQ("just.testing", proc_->GetCaptureList()[0].hostname);
}
TEST_F(HostResolverImplTest, FailedAsynchronousLookup) {
proc_->AddRuleForAllFamilies(std::string(),
"0.0.0.0"); // Default to failures.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment