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

Unified Diff: net/dns/dns_transaction.cc

Issue 15881008: DnsTransaction::RecordLostPacketsIfAny shouldn't crash if some attempts failed to connect and thus … (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments. Created 7 years, 7 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 a6a57410de41b6dcd1dc5e21cd4f09977cbd30f1..e13f1181747514b8cce0c0cdb30b048c240c20d8 100644
--- a/net/dns/dns_transaction.cc
+++ b/net/dns/dns_transaction.cc
@@ -802,14 +802,16 @@ class DnsTransactionImpl : public DnsTransaction,
if (first_completed == attempts_.size())
return;
- std::vector<int> num_rounds(session_->config().nameservers.size());
+ size_t num_servers = session_->config().nameservers.size();
for (size_t i = 0; i < first_completed; ++i) {
- unsigned server_index = attempts_[i]->GetServerIndex();
- int server_round = num_rounds[server_index]++;
// Don't record lost packet unless attempt is in pending state.
if (!attempts_[i]->is_pending())
continue;
- session_->RecordLostPacket(server_index, server_round);
+ unsigned server_index = attempts_[i]->GetServerIndex();
+ // Servers are rotated in round robin, so server round can be calculated
+ // from attempt index.
+ size_t server_round = i / num_servers;
+ session_->RecordLostPacket(server_index, static_cast<int>(server_round));
}
}
« 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