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

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

Issue 1422623015: Do not delete a connection until it has not received anything for 30 seconds. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Created 5 years, 1 month 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 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1121 // A connection that hasn't passed its minimum lifetime is still alive. 1121 // A connection that hasn't passed its minimum lifetime is still alive.
1122 // We do this to prevent connections from being pruned too quickly 1122 // We do this to prevent connections from being pruned too quickly
1123 // during a network change event when two networks would be up 1123 // during a network change event when two networks would be up
1124 // simultaneously but only for a brief period. 1124 // simultaneously but only for a brief period.
1125 return false; 1125 return false;
1126 } 1126 }
1127 1127
1128 if (receiving_) { 1128 if (receiving_) {
1129 // A connection that is receiving is alive. 1129 // A connection that is receiving is alive.
1130 return false; 1130 return false;
1131 } 1131 }
pthatcher1 2015/11/11 21:04:54 Can we just remove this check because it's covered
honghaiz3 2015/11/12 00:27:10 Done. I thought this could be a shortcut for early
1132 1132
1133 // A connection is alive until it is inactive. 1133 // A connection is alive if it is active (not write-timeout).
1134 return !active(); 1134 if (active()) {
1135 return false;
1136 }
pthatcher1 2015/11/11 21:04:54 Can we just remove this part because it's covered
honghaiz3 2015/11/12 00:27:10 Done. I guess OK to remove it. write-timeout depen
1135 1137
1136 // TODO(honghaiz): Move from using the write state to using the receiving 1138 // It is dead if it has not received anything for
1137 // state with something like the following: 1139 // DEAD_CONNECTION_RECEIVE_TIMEOUT milliseconds.
1138 // return (now > (last_received() + DEAD_CONNECTION_RECEIVE_TIMEOUT)); 1140 return (now > (last_received() + DEAD_CONNECTION_RECEIVE_TIMEOUT));
1139 } 1141 }
1140 1142
1141 std::string Connection::ToDebugId() const { 1143 std::string Connection::ToDebugId() const {
1142 std::stringstream ss; 1144 std::stringstream ss;
1143 ss << std::hex << this; 1145 ss << std::hex << this;
1144 return ss.str(); 1146 return ss.str();
1145 } 1147 }
1146 1148
1147 std::string Connection::ToString() const { 1149 std::string Connection::ToString() const {
1148 const char CONNECT_STATE_ABBREV[2] = { 1150 const char CONNECT_STATE_ABBREV[2] = {
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1295 } 1297 }
1296 } 1298 }
1297 1299
1298 void Connection::OnMessage(rtc::Message *pmsg) { 1300 void Connection::OnMessage(rtc::Message *pmsg) {
1299 ASSERT(pmsg->message_id == MSG_DELETE); 1301 ASSERT(pmsg->message_id == MSG_DELETE);
1300 LOG_J(LS_INFO, this) << "Connection deleted"; 1302 LOG_J(LS_INFO, this) << "Connection deleted";
1301 SignalDestroyed(this); 1303 SignalDestroyed(this);
1302 delete this; 1304 delete this;
1303 } 1305 }
1304 1306
1305 uint32_t Connection::last_received() { 1307 uint32_t Connection::last_received() const {
1306 return std::max(last_data_received_, 1308 return std::max(last_data_received_,
1307 std::max(last_ping_received_, last_ping_response_received_)); 1309 std::max(last_ping_received_, last_ping_response_received_));
1308 } 1310 }
1309 1311
1310 size_t Connection::recv_bytes_second() { 1312 size_t Connection::recv_bytes_second() {
1311 return recv_rate_tracker_.ComputeRate(); 1313 return recv_rate_tracker_.ComputeRate();
1312 } 1314 }
1313 1315
1314 size_t Connection::recv_total_bytes() { 1316 size_t Connection::recv_total_bytes() {
1315 return recv_rate_tracker_.TotalSampleCount(); 1317 return recv_rate_tracker_.TotalSampleCount();
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1414 ASSERT(sent < 0); 1416 ASSERT(sent < 0);
1415 error_ = port_->GetError(); 1417 error_ = port_->GetError();
1416 sent_packets_discarded_++; 1418 sent_packets_discarded_++;
1417 } else { 1419 } else {
1418 send_rate_tracker_.AddSamples(sent); 1420 send_rate_tracker_.AddSamples(sent);
1419 } 1421 }
1420 return sent; 1422 return sent;
1421 } 1423 }
1422 1424
1423 } // namespace cricket 1425 } // namespace cricket
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698