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

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

Issue 2009763002: Ping connections with the fast rate until each connection is pinged at least three times. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Created 4 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
Index: webrtc/p2p/base/p2ptransportchannel.cc
diff --git a/webrtc/p2p/base/p2ptransportchannel.cc b/webrtc/p2p/base/p2ptransportchannel.cc
index 92bec6f8970a95878fcb5fe3ed20cb7ed43c1603..fd962d549769a262d717f7f14d276629a24cf927 100644
--- a/webrtc/p2p/base/p2ptransportchannel.cc
+++ b/webrtc/p2p/base/p2ptransportchannel.cc
@@ -1302,9 +1302,15 @@ void P2PTransportChannel::OnCheckAndPing() {
// Make sure the states of the connections are up-to-date (since this affects
// which ones are pingable).
UpdateConnectionStates();
- // When the best connection is either not receiving or not writable,
- // switch to weak ping interval.
- int ping_interval = weak() ? weak_ping_interval_ : STRONG_PING_INTERVAL;
+ // When the best connection is receiving and writable, and all connections
+ // have been pinged sufficiently, switch to strong (longer) ping interval.
+ bool all_connections_pinged_sufficiently = std::all_of(
+ connections_.begin(), connections_.end(), [](Connection* conn) {
+ return !conn->active() || conn->num_pings_sent() >= kMinNumPingsSent;
+ });
+ int ping_interval = (all_connections_pinged_sufficiently && !weak())
+ ? STRONG_PING_INTERVAL
pthatcher1 2016/05/25 17:29:13 This might be more clear as : bool need_more_ping
honghaiz3 2016/05/25 18:40:02 Done.
+ : weak_ping_interval_;
if (rtc::TimeMillis() >= last_ping_sent_ms_ + ping_interval) {
Connection* conn = FindNextPingableConnection();
if (conn) {

Powered by Google App Engine
This is Rietveld 408576698