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

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: Address comments 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
« no previous file with comments | « webrtc/p2p/base/p2ptransportchannel.h ('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 92bec6f8970a95878fcb5fe3ed20cb7ed43c1603..f8466e2450d1bd16ed70bfcfc4f6b610383a763b 100644
--- a/webrtc/p2p/base/p2ptransportchannel.cc
+++ b/webrtc/p2p/base/p2ptransportchannel.cc
@@ -1302,9 +1302,16 @@ 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 not receiving or not writable, or any active
+ // connection has not been pinged enough times, use the weak ping interval.
+ bool need_more_pings_at_weak_interval = std::any_of(
+ connections_.begin(), connections_.end(), [](Connection* conn) {
+ return conn->active() &&
+ conn->num_pings_sent() < MIN_PINGS_AT_WEAK_PING_INTERVAL;
+ });
+ int ping_interval = (weak() || need_more_pings_at_weak_interval)
+ ? weak_ping_interval_
+ : STRONG_PING_INTERVAL;
if (rtc::TimeMillis() >= last_ping_sent_ms_ + ping_interval) {
Connection* conn = FindNextPingableConnection();
if (conn) {
« no previous file with comments | « webrtc/p2p/base/p2ptransportchannel.h ('k') | webrtc/p2p/base/p2ptransportchannel_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698