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

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

Issue 2069493002: Do not switch best connection on the controlled side too frequently (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Updates a comment Created 4 years, 6 months 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 938 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 std::string remote_ufrag; 949 std::string remote_ufrag;
950 const rtc::SocketAddress& addr(remote_candidate_.address()); 950 const rtc::SocketAddress& addr(remote_candidate_.address());
951 if (!port_->GetStunMessage(data, size, addr, &msg, &remote_ufrag)) { 951 if (!port_->GetStunMessage(data, size, addr, &msg, &remote_ufrag)) {
952 // The packet did not parse as a valid STUN message 952 // The packet did not parse as a valid STUN message
953 // This is a data packet, pass it along. 953 // This is a data packet, pass it along.
954 set_receiving(true); 954 set_receiving(true);
955 last_data_received_ = rtc::TimeMillis(); 955 last_data_received_ = rtc::TimeMillis();
956 recv_rate_tracker_.AddSamples(size); 956 recv_rate_tracker_.AddSamples(size);
957 SignalReadPacket(this, data, size, packet_time); 957 SignalReadPacket(this, data, size, packet_time);
958 958
959 // If timed out sending writability checks, start up again 959 // Start up again if timed out sending writability checks, or
960 if (!pruned_ && (write_state_ == STATE_WRITE_TIMEOUT)) { 960 // this is nominated on the controlled side because on the controlled side,
961 // because receiving data will increase its priority in the pruning process.
pthatcher1 2016/06/22 06:36:34 I don't understand this comment.
honghaiz3 2016/06/22 08:03:17 Revised.
962 if (write_state_ == STATE_WRITE_TIMEOUT && (nominated() || !pruned_)) {
961 LOG(LS_WARNING) << "Received a data packet on a timed-out Connection. " 963 LOG(LS_WARNING) << "Received a data packet on a timed-out Connection. "
962 << "Resetting state to STATE_WRITE_INIT."; 964 << "Resetting state to STATE_WRITE_INIT.";
963 set_write_state(STATE_WRITE_INIT); 965 ResetWriteStateAndUnprune();
pthatcher1 2016/06/22 06:36:34 So the change is to unprune when we received media
honghaiz3 2016/06/22 08:03:17 I think there is a bug in the existing code that s
964 } 966 }
965 } else if (!msg) { 967 } else if (!msg) {
966 // The packet was STUN, but failed a check and was handled internally. 968 // The packet was STUN, but failed a check and was handled internally.
967 } else { 969 } else {
968 // The packet is STUN and passed the Port checks. 970 // The packet is STUN and passed the Port checks.
969 // Perform our own checks to ensure this packet is valid. 971 // Perform our own checks to ensure this packet is valid.
970 // If this is a STUN request, then update the receiving bit and respond. 972 // If this is a STUN request, then update the receiving bit and respond.
971 // If this is a STUN response, then update the writable bit. 973 // If this is a STUN response, then update the writable bit.
972 // Log at LS_INFO if we receive a ping on an unwritable connection. 974 // Log at LS_INFO if we receive a ping on an unwritable connection.
973 rtc::LoggingSeverity sev = (!writable() ? rtc::LS_INFO : rtc::LS_VERBOSE); 975 rtc::LoggingSeverity sev = (!writable() ? rtc::LS_INFO : rtc::LS_VERBOSE);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1028 // Received conflicting role from the peer. 1030 // Received conflicting role from the peer.
1029 LOG(LS_INFO) << "Received conflicting role from the peer."; 1031 LOG(LS_INFO) << "Received conflicting role from the peer.";
1030 return; 1032 return;
1031 } 1033 }
1032 1034
1033 stats_.recv_ping_requests++; 1035 stats_.recv_ping_requests++;
1034 1036
1035 // This is a validated stun request from remote peer. 1037 // This is a validated stun request from remote peer.
1036 port_->SendBindingResponse(msg, remote_addr); 1038 port_->SendBindingResponse(msg, remote_addr);
1037 1039
1038 // If it timed out on writing check, start up again 1040 // Whether it is nominated in this request but not nominated before.
1039 if (!pruned_ && write_state_ == STATE_WRITE_TIMEOUT) { 1041 bool just_nominated = false;
1040 set_write_state(STATE_WRITE_INIT);
1041 }
1042
1043 if (port_->GetIceRole() == ICEROLE_CONTROLLED) { 1042 if (port_->GetIceRole() == ICEROLE_CONTROLLED) {
1044 const StunByteStringAttribute* use_candidate_attr = 1043 bool use_candidate = msg->GetByteString(STUN_ATTR_USE_CANDIDATE) != nullptr;
1045 msg->GetByteString(STUN_ATTR_USE_CANDIDATE); 1044 if (use_candidate) {
1046 if (use_candidate_attr) { 1045 if (!nominated()) {
1046 just_nominated = true;
1047 }
1047 set_nominated(true); 1048 set_nominated(true);
1048 SignalNominated(this); 1049 SignalNominated(this);
1049 } 1050 }
1050 } 1051 }
1052 // If it timed out on writing check, start up again if it is not pruned or
1053 // it is just nominated now, because the nomination may increase its priority
1054 // in the pruning process.
1055 if (write_state_ == STATE_WRITE_TIMEOUT && (just_nominated || !pruned_)) {
Taylor Brandstetter 2016/06/21 18:33:26 Why is the connection only restored if it's "just_
pthatcher1 2016/06/22 06:36:34 Yeah, I don't understand the "just nominated" logi
honghaiz3 2016/06/22 08:03:17 I think you are right. I may have over-thought thi
honghaiz3 2016/06/22 08:03:17 See my reply in the above comments.
1056 ResetWriteStateAndUnprune();
1057 }
1058
1051 // Set the remote cost if the network_info attribute is available. 1059 // Set the remote cost if the network_info attribute is available.
1052 // Note: If packets are re-ordered, we may get incorrect network cost 1060 // Note: If packets are re-ordered, we may get incorrect network cost
1053 // temporarily, but it should get the correct value shortly after that. 1061 // temporarily, but it should get the correct value shortly after that.
1054 const StunUInt32Attribute* network_attr = 1062 const StunUInt32Attribute* network_attr =
1055 msg->GetUInt32(STUN_ATTR_NETWORK_INFO); 1063 msg->GetUInt32(STUN_ATTR_NETWORK_INFO);
1056 if (network_attr) { 1064 if (network_attr) {
1057 uint32_t network_info = network_attr->value(); 1065 uint32_t network_info = network_attr->value();
1058 uint16_t network_cost = static_cast<uint16_t>(network_info); 1066 uint16_t network_cost = static_cast<uint16_t>(network_info);
1059 if (network_cost != remote_candidate_.network_cost()) { 1067 if (network_cost != remote_candidate_.network_cost()) {
1060 remote_candidate_.set_network_cost(network_cost); 1068 remote_candidate_.set_network_cost(network_cost);
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
1508 ASSERT(sent < 0); 1516 ASSERT(sent < 0);
1509 error_ = port_->GetError(); 1517 error_ = port_->GetError();
1510 stats_.sent_discarded_packets++; 1518 stats_.sent_discarded_packets++;
1511 } else { 1519 } else {
1512 send_rate_tracker_.AddSamples(sent); 1520 send_rate_tracker_.AddSamples(sent);
1513 } 1521 }
1514 return sent; 1522 return sent;
1515 } 1523 }
1516 1524
1517 } // namespace cricket 1525 } // namespace cricket
OLDNEW
« webrtc/p2p/base/p2ptransportchannel_unittest.cc ('K') | « webrtc/p2p/base/port.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698