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

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

Issue 2936553003: Adding PortAllocator option to support cases where sockets can't be bound. (Closed)
Patch Set: Created 3 years, 6 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
Index: webrtc/p2p/base/p2ptransportchannel.cc
diff --git a/webrtc/p2p/base/p2ptransportchannel.cc b/webrtc/p2p/base/p2ptransportchannel.cc
index 5bb6cf8aa4b20344e15b1786fc462ea08d3a568a..d22b6b5e86ed4ff3e03690736041d21b6d831962 100644
--- a/webrtc/p2p/base/p2ptransportchannel.cc
+++ b/webrtc/p2p/base/p2ptransportchannel.cc
@@ -1353,15 +1353,27 @@ void P2PTransportChannel::PruneConnections() {
// switch. If |best_conn_on_network| is not connected, we may be reconnecting
// a TCP connection and should not prune connections in this network.
// See the big comment in CompareConnectionStates.
+ //
+ // An exception is made for connections on an "any address" network, meaning
+ // not bound to any specific network interface. We don't want to keep one of
+ // these alive as a backup, since it could be using the same network
+ // interface as the higher-priority, selected candidate pair.
auto best_connection_by_network = GetBestConnectionByNetwork();
for (Connection* conn : connections_) {
- // Do not prune connections if the current best connection on this network
- // is weak. Otherwise, it may delete connections prematurely.
- Connection* best_conn_on_network =
- best_connection_by_network[conn->port()->Network()];
- if (best_conn_on_network && conn != best_conn_on_network &&
- !best_conn_on_network->weak() &&
- CompareConnectionCandidates(best_conn_on_network, conn) >= 0) {
+ // Compare aainst the best connection across all networks for a connection
+ // on an "any address" network, and otherwise compare only against the
+ // per-network best connection, to ensure one connection per network stays
+ // active.
+ Connection* to_compare;
+ if (rtc::IPIsAny(conn->port()->Network()->ip())) {
+ to_compare = selected_connection_;
+ } else {
+ to_compare = best_connection_by_network[conn->port()->Network()];
+ }
+ // Do not prune connections if the connection being compared against is
+ // weak. Otherwise, it may delete connections prematurely.
+ if (to_compare && conn != to_compare && !to_compare->weak() &&
+ CompareConnectionCandidates(to_compare, conn) >= 0) {
conn->Prune();
}
}

Powered by Google App Engine
This is Rietveld 408576698