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 1331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1342 // how a TCP connection is kicked into reconnecting on the active side. | 1342 // how a TCP connection is kicked into reconnecting on the active side. |
1343 bool P2PTransportChannel::IsPingable(Connection* conn, int64_t now) { | 1343 bool P2PTransportChannel::IsPingable(Connection* conn, int64_t now) { |
1344 const Candidate& remote = conn->remote_candidate(); | 1344 const Candidate& remote = conn->remote_candidate(); |
1345 // We should never get this far with an empty remote ufrag. | 1345 // We should never get this far with an empty remote ufrag. |
1346 ASSERT(!remote.username().empty()); | 1346 ASSERT(!remote.username().empty()); |
1347 if (remote.username().empty() || remote.password().empty()) { | 1347 if (remote.username().empty() || remote.password().empty()) { |
1348 // If we don't have an ICE ufrag and pwd, there's no way we can ping. | 1348 // If we don't have an ICE ufrag and pwd, there's no way we can ping. |
1349 return false; | 1349 return false; |
1350 } | 1350 } |
1351 | 1351 |
1352 // A failed connection will not be pinged. | |
1353 if (conn->state() == Connection::STATE_FAILED) { | |
1354 return false; | |
1355 } | |
1356 | |
1357 // An never connected connection cannot be written to at all, so pinging is | 1352 // An never connected connection cannot be written to at all, so pinging is |
1358 // out of the question. However, if it has become WRITABLE, it is in the | 1353 // out of the question. However, if it has become WRITABLE, it is in the |
1359 // reconnecting state so ping is needed. | 1354 // reconnecting state so ping is needed. |
1360 if (!conn->connected() && !conn->writable()) { | 1355 if (!conn->connected() && !conn->writable()) { |
1361 return false; | 1356 return false; |
1362 } | 1357 } |
1363 | 1358 |
1364 // If the channel is weakly connected, ping all connections. | 1359 // If the channel is weakly connected, ping all connections. |
1365 if (weak()) { | 1360 if (weak()) { |
1366 return true; | 1361 return true; |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1715 | 1710 |
1716 // During the initial state when nothing has been pinged yet, return the first | 1711 // During the initial state when nothing has been pinged yet, return the first |
1717 // one in the ordered |connections_|. | 1712 // one in the ordered |connections_|. |
1718 return *(std::find_if(connections_.begin(), connections_.end(), | 1713 return *(std::find_if(connections_.begin(), connections_.end(), |
1719 [conn1, conn2](Connection* conn) { | 1714 [conn1, conn2](Connection* conn) { |
1720 return conn == conn1 || conn == conn2; | 1715 return conn == conn1 || conn == conn2; |
1721 })); | 1716 })); |
1722 } | 1717 } |
1723 | 1718 |
1724 } // namespace cricket | 1719 } // namespace cricket |
OLD | NEW |