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

Unified Diff: webrtc/p2p/base/p2ptransportchannel.cc

Issue 2232563002: Do not switch to a high-cost connection that is not receiving (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: . Created 4 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 | webrtc/p2p/base/p2ptransportchannel_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/base/p2ptransportchannel.cc
diff --git a/webrtc/p2p/base/p2ptransportchannel.cc b/webrtc/p2p/base/p2ptransportchannel.cc
index 085185b172fffe7191a4117ff28fe809c29ca7cb..b16667da04bc3c83d666319cd1064193d744ab0c 100644
--- a/webrtc/p2p/base/p2ptransportchannel.cc
+++ b/webrtc/p2p/base/p2ptransportchannel.cc
@@ -183,6 +183,8 @@ void P2PTransportChannel::AddConnection(Connection* connection) {
// b) last data received time.
// iii) Lower cost / higher priority.
// iv) rtt.
+// To further prevent switching to high-cost networks, does not switch to
+// a high-cost connection if it is not receiving.
// TODO(honghaiz): Stop the aggressive nomination on the controlling side and
// implement the ice-renomination option.
bool P2PTransportChannel::ShouldSwitchSelectedConnection(
@@ -196,6 +198,14 @@ bool P2PTransportChannel::ShouldSwitchSelectedConnection(
return true;
}
+ // Do not switch to a connection that is not receiving if it has higher cost
+ // because it may be just spuriously better.
+ if (new_connection->ComputeNetworkCost() >
+ selected_connection_->ComputeNetworkCost() &&
+ !new_connection->receiving()) {
+ return false;
+ }
+
rtc::Optional<int64_t> receiving_unchanged_threshold(
rtc::TimeMillis() - config_.receiving_switching_delay.value_or(0));
int cmp = CompareConnections(selected_connection_, new_connection,
@@ -1522,7 +1532,8 @@ bool P2PTransportChannel::IsPingable(const Connection* conn,
// Always ping active connections regardless whether the channel is completed
// or not, but backup connections are pinged at a slower rate.
if (IsBackupConnection(conn)) {
- return (now >= conn->last_ping_response_received() +
+ return conn->rtt_samples() == 0 ||
+ (now >= conn->last_ping_response_received() +
config_.backup_connection_ping_interval);
}
// Don't ping inactive non-backup connections.
« no previous file with comments | « no previous file | webrtc/p2p/base/p2ptransportchannel_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698