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 1345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1356 // how a TCP connection is kicked into reconnecting on the active side. | 1356 // how a TCP connection is kicked into reconnecting on the active side. |
1357 bool P2PTransportChannel::IsPingable(Connection* conn, int64_t now) { | 1357 bool P2PTransportChannel::IsPingable(Connection* conn, int64_t now) { |
1358 const Candidate& remote = conn->remote_candidate(); | 1358 const Candidate& remote = conn->remote_candidate(); |
1359 // We should never get this far with an empty remote ufrag. | 1359 // We should never get this far with an empty remote ufrag. |
1360 ASSERT(!remote.username().empty()); | 1360 ASSERT(!remote.username().empty()); |
1361 if (remote.username().empty() || remote.password().empty()) { | 1361 if (remote.username().empty() || remote.password().empty()) { |
1362 // If we don't have an ICE ufrag and pwd, there's no way we can ping. | 1362 // If we don't have an ICE ufrag and pwd, there's no way we can ping. |
1363 return false; | 1363 return false; |
1364 } | 1364 } |
1365 | 1365 |
| 1366 // A failed connection will not be pinged. |
| 1367 if (conn->state() == Connection::STATE_FAILED) { |
| 1368 return false; |
| 1369 } |
| 1370 |
1366 // An never connected connection cannot be written to at all, so pinging is | 1371 // An never connected connection cannot be written to at all, so pinging is |
1367 // out of the question. However, if it has become WRITABLE, it is in the | 1372 // out of the question. However, if it has become WRITABLE, it is in the |
1368 // reconnecting state so ping is needed. | 1373 // reconnecting state so ping is needed. |
1369 if (!conn->connected() && !conn->writable()) { | 1374 if (!conn->connected() && !conn->writable()) { |
1370 return false; | 1375 return false; |
1371 } | 1376 } |
1372 | 1377 |
1373 // If the channel is weakly connected, ping all connections. | 1378 // If the channel is weakly connected, ping all connections. |
1374 if (weak()) { | 1379 if (weak()) { |
1375 return true; | 1380 return true; |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1688 | 1693 |
1689 // During the initial state when nothing has been pinged yet, return the first | 1694 // During the initial state when nothing has been pinged yet, return the first |
1690 // one in the ordered |connections_|. | 1695 // one in the ordered |connections_|. |
1691 return *(std::find_if(connections_.begin(), connections_.end(), | 1696 return *(std::find_if(connections_.begin(), connections_.end(), |
1692 [conn1, conn2](Connection* conn) { | 1697 [conn1, conn2](Connection* conn) { |
1693 return conn == conn1 || conn == conn2; | 1698 return conn == conn1 || conn == conn2; |
1694 })); | 1699 })); |
1695 } | 1700 } |
1696 | 1701 |
1697 } // namespace cricket | 1702 } // namespace cricket |
OLD | NEW |