OLD | NEW |
---|---|
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 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1117 // connection back to life, but if we don't really want it, we can always | 1117 // connection back to life, but if we don't really want it, we can always |
1118 // prune it again. | 1118 // prune it again. |
1119 set_receiving(true); | 1119 set_receiving(true); |
1120 set_write_state(STATE_WRITABLE); | 1120 set_write_state(STATE_WRITABLE); |
1121 set_state(STATE_SUCCEEDED); | 1121 set_state(STATE_SUCCEEDED); |
1122 pings_since_last_response_.clear(); | 1122 pings_since_last_response_.clear(); |
1123 last_ping_response_received_ = rtc::Time(); | 1123 last_ping_response_received_ = rtc::Time(); |
1124 } | 1124 } |
1125 | 1125 |
1126 bool Connection::dead(uint32_t now) const { | 1126 bool Connection::dead(uint32_t now) const { |
1127 if (now < (time_created_ms_ + MIN_CONNECTION_LIFETIME)) { | 1127 if (last_received() == 0) { |
1128 // A connection that hasn't passed its minimum lifetime is still alive. | 1128 // If a connection has never received anything, it will be dead only if |
1129 // We do this to prevent connections from being pruned too quickly | 1129 // it is inactive and has passed its minimum lifetime. We do this to prevent |
1130 // during a network change event when two networks would be up | 1130 // a connection may be deleted too quickly because it has not got a chance |
1131 // simultaneously but only for a brief period. | 1131 // to be pinged, or it may be pruned too quickly during a network change |
1132 return false; | 1132 // event when two networks would be up simultaneously but only for a |
1133 // brief period. | |
1134 return !active() && now > (time_created_ms_ + MIN_CONNECTION_LIFETIME); | |
1133 } | 1135 } |
pthatcher1
2015/12/30 17:12:28
Let me see if I understand the purpose of this CL
honghaiz3
2015/12/30 19:38:18
Yes. More precisely, having 10 seconds for the min
| |
1134 | 1136 |
1135 // It is dead if it has not received anything for | 1137 // It is dead if it has not received anything for |
1136 // DEAD_CONNECTION_RECEIVE_TIMEOUT milliseconds. | 1138 // DEAD_CONNECTION_RECEIVE_TIMEOUT milliseconds. |
1137 return (now > (last_received() + DEAD_CONNECTION_RECEIVE_TIMEOUT)); | 1139 return (now > (last_received() + DEAD_CONNECTION_RECEIVE_TIMEOUT)); |
1138 } | 1140 } |
1139 | 1141 |
1140 std::string Connection::ToDebugId() const { | 1142 std::string Connection::ToDebugId() const { |
1141 std::stringstream ss; | 1143 std::stringstream ss; |
1142 ss << std::hex << this; | 1144 ss << std::hex << this; |
1143 return ss.str(); | 1145 return ss.str(); |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1412 ASSERT(sent < 0); | 1414 ASSERT(sent < 0); |
1413 error_ = port_->GetError(); | 1415 error_ = port_->GetError(); |
1414 sent_packets_discarded_++; | 1416 sent_packets_discarded_++; |
1415 } else { | 1417 } else { |
1416 send_rate_tracker_.AddSamples(sent); | 1418 send_rate_tracker_.AddSamples(sent); |
1417 } | 1419 } |
1418 return sent; | 1420 return sent; |
1419 } | 1421 } |
1420 | 1422 |
1421 } // namespace cricket | 1423 } // namespace cricket |
OLD | NEW |