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

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

Issue 2936553003: Adding PortAllocator option to support cases where sockets can't be bound. (Closed)
Patch Set: Minor changes (comments, renaming, etc.) 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
« no previous file with comments | « webrtc/p2p/base/basicpacketsocketfactory.cc ('k') | 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 5bb6cf8aa4b20344e15b1786fc462ea08d3a568a..8853ccaa2f5d89efa110825339dec3b62781de64 100644
--- a/webrtc/p2p/base/p2ptransportchannel.cc
+++ b/webrtc/p2p/base/p2ptransportchannel.cc
@@ -1353,15 +1353,26 @@ 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) {
+ Connection* best_conn = selected_connection_;
+ if (!rtc::IPIsAny(conn->port()->Network()->ip())) {
+ // If the connection is bound to a specific network interface (not an
+ // "any address" network), compare it against the best connection for
+ // that network interface rather than the best connection overall. This
+ // ensures that at least one connection per network will be left
+ // unpruned.
+ best_conn = 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 (best_conn && conn != best_conn && !best_conn->weak() &&
+ CompareConnectionCandidates(best_conn, conn) >= 0) {
conn->Prune();
}
}
« no previous file with comments | « webrtc/p2p/base/basicpacketsocketfactory.cc ('k') | webrtc/p2p/base/p2ptransportchannel_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698