Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(702)

Unified Diff: net/dns/dns_transaction.cc

Issue 10824238: [net/dns] Don't abandon a DnsUDPAttempt when the response does not match the query. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Handle sync and async cases. Add test. Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/dns/dns_transaction_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/dns/dns_transaction.cc
diff --git a/net/dns/dns_transaction.cc b/net/dns/dns_transaction.cc
index 00d8064f6e8d6f263423659519e9691a99e406aa..a9390a2547dc0e8aaef8eec8bc1317d6214796aa 100644
--- a/net/dns/dns_transaction.cc
+++ b/net/dns/dns_transaction.cc
@@ -71,6 +71,7 @@ class DnsUDPAttempt {
scoped_ptr<DnsQuery> query,
const CompletionCallback& callback)
: next_state_(STATE_NONE),
+ received_malformed_response_(false),
socket_(socket.Pass()),
server_(server),
query_(query.Pass()),
@@ -150,8 +151,7 @@ class DnsUDPAttempt {
break;
}
} while (rv != ERR_IO_PENDING && next_state_ != STATE_NONE);
-
- return rv;
+ return received_malformed_response_ ? ERR_DNS_MALFORMED_RESPONSE : rv;
mmenke 2012/08/28 14:15:54 Err...How does this work? It looks like if we eve
szym 2012/08/28 14:59:44 You're right. This isn't finished yet, and the tes
}
int DoConnect() {
@@ -196,12 +196,14 @@ class DnsUDPAttempt {
DCHECK(rv);
if (!response_->InitParse(rv, *query_)) {
- // TODO(szym): Consider making this reaction less aggressive.
// Other implementations simply ignore mismatched responses. Since each
// DnsUDPAttempt binds to a different port, we might find that responses
// to previously timed out queries lead to failures in the future.
- // http://crbug.com/107413
- return ERR_DNS_MALFORMED_RESPONSE;
+ // Our solution is to make another attempt, in case the query truly
+ // failed, but keep this attempt alive, in case it was a false alarm.
+ received_malformed_response_ = true;
+ next_state_ = STATE_READ_RESPONSE;
+ return ERR_IO_PENDING;
}
if (response_->flags() & dns_protocol::kFlagTC)
return ERR_DNS_SERVER_REQUIRES_TCP;
@@ -222,6 +224,7 @@ class DnsUDPAttempt {
}
State next_state_;
+ bool received_malformed_response_;
scoped_ptr<DatagramClientSocket> socket_;
IPEndPoint server_;
« no previous file with comments | « no previous file | net/dns/dns_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698