Index: webrtc/p2p/base/p2ptransportchannel.cc |
diff --git a/webrtc/p2p/base/p2ptransportchannel.cc b/webrtc/p2p/base/p2ptransportchannel.cc |
index 206113c4ebcc554d9b401e716c5031412eda4845..4b7b2571478b66b932d8ebe544281fe64eb3068f 100644 |
--- a/webrtc/p2p/base/p2ptransportchannel.cc |
+++ b/webrtc/p2p/base/p2ptransportchannel.cc |
@@ -217,10 +217,8 @@ static const int STRONG_PING_INTERVAL = 1000 * PING_PACKET_SIZE / 1000; |
// writable or not receiving. |
const int WEAK_PING_INTERVAL = 1000 * PING_PACKET_SIZE / 10000; |
-// If the current best connection is both writable and receiving, then we will |
-// also try hard to make sure it is pinged at this rate (a little less than |
-// 2 * STRONG_PING_INTERVAL). |
-static const int MAX_CURRENT_STRONG_INTERVAL = 900; // ms |
+// Writable connections are pinged at a slower rate. |
+static const int WRITABLE_CONNECTION_PING_INTERVAL = 2500; // ms |
static const int MIN_CHECK_RECEIVING_INTERVAL = 50; // ms |
@@ -250,7 +248,7 @@ P2PTransportChannel::P2PTransportChannel(const std::string& transport_name, |
0 /* backup_connection_ping_interval */, |
false /* gather_continually */, |
false /* prioritize_most_likely_candidate_pairs */, |
- MAX_CURRENT_STRONG_INTERVAL /* max_strong_interval */) { |
+ WRITABLE_CONNECTION_PING_INTERVAL /* max_strong_interval */) { |
pthatcher1
2016/05/06 23:34:38
The comment doesn't match. And the comment provid
|
uint32_t weak_ping_interval = ::strtoul( |
webrtc::field_trial::FindFullName("WebRTC-StunInterPacketDelay").c_str(), |
nullptr, 10); |
@@ -436,11 +434,13 @@ void P2PTransportChannel::SetIceConfig(const IceConfig& config) { |
LOG(LS_INFO) << "Set ping most likely connection to " |
<< config_.prioritize_most_likely_candidate_pairs; |
- if (config.max_strong_interval >= 0 && |
- config_.max_strong_interval != config.max_strong_interval) { |
- config_.max_strong_interval = config.max_strong_interval; |
- LOG(LS_INFO) << "Set max strong interval to " |
- << config_.max_strong_interval; |
+ if (config.writable_connection_ping_interval >= 0 && |
+ config_.writable_connection_ping_interval != |
+ config.writable_connection_ping_interval) { |
+ config_.writable_connection_ping_interval = |
+ config.writable_connection_ping_interval; |
+ LOG(LS_INFO) << "Set writable_connection_ping_interval to " |
+ << config_.writable_connection_ping_interval; |
} |
} |
@@ -1291,6 +1291,7 @@ void P2PTransportChannel::OnCheckAndPing() { |
MarkConnectionPinged(conn); |
} |
} |
+ |
int delay = std::min(ping_interval, check_receiving_interval_); |
thread()->PostDelayed(delay, this, MSG_CHECK_AND_PING); |
} |
@@ -1332,6 +1333,13 @@ bool P2PTransportChannel::IsPingable(Connection* conn, int64_t now) { |
return (now >= conn->last_ping_response_received() + |
config_.backup_connection_ping_interval); |
} |
+ |
+ // Writable connections are pinged at a slower rate. |
+ if (conn->writable()) { |
+ return (now >= |
+ conn->last_ping_sent() + config_.writable_connection_ping_interval); |
+ } |
+ |
return conn->active(); |
} |
@@ -1347,7 +1355,8 @@ Connection* P2PTransportChannel::FindNextPingableConnection() { |
Connection* conn_to_ping = nullptr; |
if (best_connection_ && best_connection_->connected() && |
best_connection_->writable() && |
- (best_connection_->last_ping_sent() + config_.max_strong_interval <= |
+ (best_connection_->last_ping_sent() + |
+ config_.writable_connection_ping_interval <= |
now)) { |
conn_to_ping = best_connection_; |
} else { |