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

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

Issue 1371623003: Delete a connection only if it has timed out on writing and not receiving for 10 seconds. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: A minor change in GetStats Created 5 years, 3 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 15ac006872e9087bf8af8cbe1fde783fd29f1160..bbd7c1cf0478fe0501d5e32ed9e2cdc95b0b74cb 100644
--- a/webrtc/p2p/base/p2ptransportchannel.cc
+++ b/webrtc/p2p/base/p2ptransportchannel.cc
@@ -286,23 +286,18 @@ void P2PTransportChannel::SetIceTiebreaker(uint64 tiebreaker) {
tiebreaker_ = tiebreaker;
}
-// Currently a channel is considered ICE completed once there is no
-// more than one connection per Network. This works for a single NIC
-// with both IPv4 and IPv6 enabled. However, this condition won't
-// happen when there are multiple NICs and all of them have
-// connectivity.
-// TODO(guoweis): Change Completion to be driven by a channel level
-// timer.
+// Currently a channel is considered ICE completed once there is at least one
pthatcher1 2015/09/28 23:07:27 Just remove "Currently" and say "A channel ..."
honghaiz3 2015/09/29 18:47:49 Done.
+// connection that has not timed out on writing and there is no more than one
+// such connection per Network.
pthatcher1 2015/09/28 23:07:27 This would be more clear as "once there is at leas
honghaiz3 2015/09/29 18:47:49 Done.
TransportChannelState P2PTransportChannel::GetState() const {
+ bool has_non_write_timeout_connections = false;
pthatcher1 2015/09/28 23:07:27 I think this would be much more clear as: bool Co
honghaiz3 2015/09/29 18:47:49 Done.
std::set<rtc::Network*> networks;
-
- if (connections_.empty()) {
- return had_connection_ ? TransportChannelState::STATE_FAILED
- : TransportChannelState::STATE_INIT;
- }
-
- for (uint32 i = 0; i < connections_.size(); ++i) {
- rtc::Network* network = connections_[i]->port()->Network();
+ for (Connection* connection : connections_) {
+ if (connection->write_state() == Connection::STATE_WRITE_TIMEOUT) {
+ continue;
+ }
+ has_non_write_timeout_connections = true;
+ rtc::Network* network = connection->port()->Network();
if (networks.find(network) == networks.end()) {
networks.insert(network);
} else {
@@ -312,9 +307,12 @@ TransportChannelState P2PTransportChannel::GetState() const {
return TransportChannelState::STATE_CONNECTING;
}
}
- LOG_J(LS_VERBOSE, this) << "Ice is completed for this channel.";
-
- return TransportChannelState::STATE_COMPLETED;
+ if (has_non_write_timeout_connections) {
+ LOG_J(LS_VERBOSE, this) << "Ice is completed for this channel.";
+ return TransportChannelState::STATE_COMPLETED;
+ }
+ return had_connection_ ? TransportChannelState::STATE_FAILED
+ : TransportChannelState::STATE_INIT;
}
void P2PTransportChannel::SetIceCredentials(const std::string& ice_ufrag,
@@ -872,8 +870,11 @@ bool P2PTransportChannel::GetStats(ConnectionInfos *infos) {
infos->clear();
std::vector<Connection *>::const_iterator it;
- for (it = connections_.begin(); it != connections_.end(); ++it) {
- Connection* connection = *it;
+ for (Connection* connection : connections_) {
+ if (connection->write_state() == Connection::STATE_WRITE_TIMEOUT &&
+ !connection->receiving()) {
pthatcher1 2015/09/28 23:07:27 This is basically saying "Don't report stats for c
honghaiz3 2015/09/29 18:47:49 I wanted to keep the same app behavior, but think
+ continue;
+ }
ConnectionInfo info;
info.best_connection = (best_connection_ == connection);
info.receiving = connection->receiving();
« 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