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

Side by Side Diff: webrtc/p2p/base/p2ptransportchannel.cc

Issue 1364683002: Do not prune if the current best connection is weak. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Add tests and merge Created 5 years, 2 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 : nullptr; 968 : nullptr;
969 } 969 }
970 970
971 void P2PTransportChannel::PruneConnections() { 971 void P2PTransportChannel::PruneConnections() {
972 // We can prune any connection for which there is a connected, writable 972 // We can prune any connection for which there is a connected, writable
973 // connection on the same network with better or equal priority. We leave 973 // connection on the same network with better or equal priority. We leave
974 // those with better priority just in case they become writable later (at 974 // those with better priority just in case they become writable later (at
975 // which point, we would prune out the current best connection). We leave 975 // which point, we would prune out the current best connection). We leave
976 // connections on other networks because they may not be using the same 976 // connections on other networks because they may not be using the same
977 // resources and they may represent very distinct paths over which we can 977 // resources and they may represent very distinct paths over which we can
978 // switch. If the |primier| connection is not connected, we may be 978 // switch. If the |premier| connection is not connected, we may be
979 // reconnecting a TCP connection and temporarily do not prune connections in 979 // reconnecting a TCP connection and temporarily do not prune connections in
980 // this network. See the big comment in CompareConnections. 980 // this network. See the big comment in CompareConnections.
981 981
982 // Get a list of the networks that we are using. 982 // Get a list of the networks that we are using.
983 std::set<rtc::Network*> networks; 983 std::set<rtc::Network*> networks;
984 for (const Connection* conn : connections_) { 984 for (const Connection* conn : connections_) {
985 networks.insert(conn->port()->Network()); 985 networks.insert(conn->port()->Network());
986 } 986 }
987 for (rtc::Network* network : networks) { 987 for (rtc::Network* network : networks) {
988 Connection* primier = GetBestConnectionOnNetwork(network); 988 Connection* premier = GetBestConnectionOnNetwork(network);
989 if (!(primier && primier->writable() && primier->connected())) { 989 // Do not prune connections if the current best connection is weak on this
990 // network. Otherwise, it may delete connections prematurely.
991 if (!premier || premier->Weak()) {
990 continue; 992 continue;
991 } 993 }
992 994
993 for (Connection* conn : connections_) { 995 for (Connection* conn : connections_) {
994 if ((conn != primier) && (conn->port()->Network() == network) && 996 if ((conn != premier) && (conn->port()->Network() == network) &&
995 (CompareConnectionCandidates(primier, conn) >= 0)) { 997 (CompareConnectionCandidates(premier, conn) >= 0)) {
996 conn->Prune(); 998 conn->Prune();
997 } 999 }
998 } 1000 }
999 } 1001 }
1000 } 1002 }
1001 1003
1002 // Track the best connection, and let listeners know 1004 // Track the best connection, and let listeners know
1003 void P2PTransportChannel::SwitchBestConnectionTo(Connection* conn) { 1005 void P2PTransportChannel::SwitchBestConnectionTo(Connection* conn) {
1004 // Note: if conn is NULL, the previous best_connection_ has been destroyed, 1006 // Note: if conn is NULL, the previous best_connection_ has been destroyed,
1005 // so don't use it. 1007 // so don't use it.
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
1319 } 1321 }
1320 } 1322 }
1321 1323
1322 void P2PTransportChannel::OnReadyToSend(Connection* connection) { 1324 void P2PTransportChannel::OnReadyToSend(Connection* connection) {
1323 if (connection == best_connection_ && writable()) { 1325 if (connection == best_connection_ && writable()) {
1324 SignalReadyToSend(this); 1326 SignalReadyToSend(this);
1325 } 1327 }
1326 } 1328 }
1327 1329
1328 } // namespace cricket 1330 } // namespace cricket
OLDNEW
« no previous file with comments | « no previous file | webrtc/p2p/base/p2ptransportchannel_unittest.cc » ('j') | webrtc/p2p/base/p2ptransportchannel_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698