| 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 it has ever received anything, we keep it alive until it hasn't | 
| 1129     // We do this to prevent connections from being pruned too quickly | 1129     // received anything for DEAD_CONNECTION_RECEIVE_TIMEOUT. This covers the | 
| 1130     // during a network change event when two networks would be up | 1130     // normal case of a successfully used connection that stops working. This | 
| 1131     // simultaneously but only for a brief period. | 1131     // also allows a remote peer to continue pinging over a locally inactive | 
|  | 1132     // (pruned) connection. | 
|  | 1133     return (now > (last_received() + DEAD_CONNECTION_RECEIVE_TIMEOUT)); | 
|  | 1134   } | 
|  | 1135 | 
|  | 1136   if (active()) { | 
|  | 1137     // If it has never received anything, keep it alive as long as it is | 
|  | 1138     // actively pinging and not pruned. Otherwise, the connection might be | 
|  | 1139     // deleted before it has a chance to ping. This is the normal case for a | 
|  | 1140     // new connection that is pinging but hasn't received anything yet. | 
| 1132     return false; | 1141     return false; | 
| 1133   } | 1142   } | 
| 1134 | 1143 | 
| 1135   // It is dead if it has not received anything for | 1144   // If it has never received anything and is not actively pinging (pruned), we | 
| 1136   // DEAD_CONNECTION_RECEIVE_TIMEOUT milliseconds. | 1145   // keep it around for at least MIN_CONNECTION_LIFETIME to prevent connections | 
| 1137   return (now > (last_received() + DEAD_CONNECTION_RECEIVE_TIMEOUT)); | 1146   // from being pruned too quickly during a network change event when two | 
|  | 1147   // networks would be up simultaneously but only for a brief period. | 
|  | 1148   return now > (time_created_ms_ + MIN_CONNECTION_LIFETIME); | 
| 1138 } | 1149 } | 
| 1139 | 1150 | 
| 1140 std::string Connection::ToDebugId() const { | 1151 std::string Connection::ToDebugId() const { | 
| 1141   std::stringstream ss; | 1152   std::stringstream ss; | 
| 1142   ss << std::hex << this; | 1153   ss << std::hex << this; | 
| 1143   return ss.str(); | 1154   return ss.str(); | 
| 1144 } | 1155 } | 
| 1145 | 1156 | 
| 1146 std::string Connection::ToString() const { | 1157 std::string Connection::ToString() const { | 
| 1147   const char CONNECT_STATE_ABBREV[2] = { | 1158   const char CONNECT_STATE_ABBREV[2] = { | 
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1412     ASSERT(sent < 0); | 1423     ASSERT(sent < 0); | 
| 1413     error_ = port_->GetError(); | 1424     error_ = port_->GetError(); | 
| 1414     sent_packets_discarded_++; | 1425     sent_packets_discarded_++; | 
| 1415   } else { | 1426   } else { | 
| 1416     send_rate_tracker_.AddSamples(sent); | 1427     send_rate_tracker_.AddSamples(sent); | 
| 1417   } | 1428   } | 
| 1418   return sent; | 1429   return sent; | 
| 1419 } | 1430 } | 
| 1420 | 1431 | 
| 1421 }  // namespace cricket | 1432 }  // namespace cricket | 
| OLD | NEW | 
|---|