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 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 // | 775 // |
776 // Connection | 776 // Connection |
777 // | 777 // |
778 | 778 |
779 Connection::Connection(Port* port, | 779 Connection::Connection(Port* port, |
780 size_t index, | 780 size_t index, |
781 const Candidate& remote_candidate) | 781 const Candidate& remote_candidate) |
782 : port_(port), | 782 : port_(port), |
783 local_candidate_index_(index), | 783 local_candidate_index_(index), |
784 remote_candidate_(remote_candidate), | 784 remote_candidate_(remote_candidate), |
785 read_state_(STATE_READ_INIT), | |
786 write_state_(STATE_WRITE_INIT), | 785 write_state_(STATE_WRITE_INIT), |
| 786 receiving_(false), |
787 connected_(true), | 787 connected_(true), |
788 pruned_(false), | 788 pruned_(false), |
789 use_candidate_attr_(false), | 789 use_candidate_attr_(false), |
790 nominated_(false), | 790 nominated_(false), |
791 remote_ice_mode_(ICEMODE_FULL), | 791 remote_ice_mode_(ICEMODE_FULL), |
792 requests_(port->thread()), | 792 requests_(port->thread()), |
793 rtt_(DEFAULT_RTT), | 793 rtt_(DEFAULT_RTT), |
794 last_ping_sent_(0), | 794 last_ping_sent_(0), |
795 last_ping_received_(0), | 795 last_ping_received_(0), |
796 last_data_received_(0), | 796 last_data_received_(0), |
797 last_ping_response_received_(0), | 797 last_ping_response_received_(0), |
798 recv_rate_tracker_(100u, 10u), | 798 recv_rate_tracker_(100u, 10u), |
799 send_rate_tracker_(100u, 10u), | 799 send_rate_tracker_(100u, 10u), |
800 sent_packets_discarded_(0), | 800 sent_packets_discarded_(0), |
801 sent_packets_total_(0), | 801 sent_packets_total_(0), |
802 reported_(false), | 802 reported_(false), |
803 state_(STATE_WAITING) { | 803 state_(STATE_WAITING), |
| 804 receiving_timeout_(WEAK_CONNECTION_RECEIVE_TIMEOUT) { |
804 // All of our connections start in WAITING state. | 805 // All of our connections start in WAITING state. |
805 // TODO(mallinath) - Start connections from STATE_FROZEN. | 806 // TODO(mallinath) - Start connections from STATE_FROZEN. |
806 // Wire up to send stun packets | 807 // Wire up to send stun packets |
807 requests_.SignalSendPacket.connect(this, &Connection::OnSendStunPacket); | 808 requests_.SignalSendPacket.connect(this, &Connection::OnSendStunPacket); |
808 LOG_J(LS_INFO, this) << "Connection created"; | 809 LOG_J(LS_INFO, this) << "Connection created"; |
809 } | 810 } |
810 | 811 |
811 Connection::~Connection() { | 812 Connection::~Connection() { |
812 } | 813 } |
813 | 814 |
(...skipping 20 matching lines...) Expand all Loading... |
834 g = remote_candidate_.priority(); | 835 g = remote_candidate_.priority(); |
835 d = local_candidate().priority(); | 836 d = local_candidate().priority(); |
836 } | 837 } |
837 priority = std::min(g, d); | 838 priority = std::min(g, d); |
838 priority = priority << 32; | 839 priority = priority << 32; |
839 priority += 2 * std::max(g, d) + (g > d ? 1 : 0); | 840 priority += 2 * std::max(g, d) + (g > d ? 1 : 0); |
840 } | 841 } |
841 return priority; | 842 return priority; |
842 } | 843 } |
843 | 844 |
844 void Connection::set_read_state(ReadState value) { | |
845 ReadState old_value = read_state_; | |
846 read_state_ = value; | |
847 if (value != old_value) { | |
848 LOG_J(LS_VERBOSE, this) << "set_read_state"; | |
849 SignalStateChange(this); | |
850 CheckTimeout(); | |
851 } | |
852 } | |
853 | |
854 void Connection::set_write_state(WriteState value) { | 845 void Connection::set_write_state(WriteState value) { |
855 WriteState old_value = write_state_; | 846 WriteState old_value = write_state_; |
856 write_state_ = value; | 847 write_state_ = value; |
857 if (value != old_value) { | 848 if (value != old_value) { |
858 LOG_J(LS_VERBOSE, this) << "set_write_state from: " << old_value << " to " | 849 LOG_J(LS_VERBOSE, this) << "set_write_state from: " << old_value << " to " |
859 << value; | 850 << value; |
860 SignalStateChange(this); | 851 SignalStateChange(this); |
861 CheckTimeout(); | 852 CheckTimeout(); |
862 } | 853 } |
863 } | 854 } |
864 | 855 |
| 856 void Connection::set_receiving(bool value) { |
| 857 if (value != receiving_) { |
| 858 LOG_J(LS_VERBOSE, this) << "set_receiving to " << value; |
| 859 receiving_ = value; |
| 860 SignalStateChange(this); |
| 861 CheckTimeout(); |
| 862 } |
| 863 } |
| 864 |
865 void Connection::set_state(State state) { | 865 void Connection::set_state(State state) { |
866 State old_state = state_; | 866 State old_state = state_; |
867 state_ = state; | 867 state_ = state; |
868 if (state != old_state) { | 868 if (state != old_state) { |
869 LOG_J(LS_VERBOSE, this) << "set_state"; | 869 LOG_J(LS_VERBOSE, this) << "set_state"; |
870 } | 870 } |
871 } | 871 } |
872 | 872 |
873 void Connection::set_connected(bool value) { | 873 void Connection::set_connected(bool value) { |
874 bool old_value = connected_; | 874 bool old_value = connected_; |
(...skipping 20 matching lines...) Expand all Loading... |
895 } | 895 } |
896 } | 896 } |
897 | 897 |
898 void Connection::OnReadPacket( | 898 void Connection::OnReadPacket( |
899 const char* data, size_t size, const rtc::PacketTime& packet_time) { | 899 const char* data, size_t size, const rtc::PacketTime& packet_time) { |
900 rtc::scoped_ptr<IceMessage> msg; | 900 rtc::scoped_ptr<IceMessage> msg; |
901 std::string remote_ufrag; | 901 std::string remote_ufrag; |
902 const rtc::SocketAddress& addr(remote_candidate_.address()); | 902 const rtc::SocketAddress& addr(remote_candidate_.address()); |
903 if (!port_->GetStunMessage(data, size, addr, msg.accept(), &remote_ufrag)) { | 903 if (!port_->GetStunMessage(data, size, addr, msg.accept(), &remote_ufrag)) { |
904 // The packet did not parse as a valid STUN message | 904 // The packet did not parse as a valid STUN message |
| 905 // This is a data packet, pass it along. |
| 906 set_receiving(true); |
| 907 last_data_received_ = rtc::Time(); |
| 908 recv_rate_tracker_.AddSamples(size); |
| 909 SignalReadPacket(this, data, size, packet_time); |
905 | 910 |
906 // If this connection is readable, then pass along the packet. | 911 // If timed out sending writability checks, start up again |
907 if (read_state_ == STATE_READABLE) { | 912 if (!pruned_ && (write_state_ == STATE_WRITE_TIMEOUT)) { |
908 // readable means data from this address is acceptable | 913 LOG(LS_WARNING) << "Received a data packet on a timed-out Connection. " |
909 // Send it on! | 914 << "Resetting state to STATE_WRITE_INIT."; |
910 last_data_received_ = rtc::Time(); | 915 set_write_state(STATE_WRITE_INIT); |
911 recv_rate_tracker_.AddSamples(size); | |
912 SignalReadPacket(this, data, size, packet_time); | |
913 | |
914 // If timed out sending writability checks, start up again | |
915 if (!pruned_ && (write_state_ == STATE_WRITE_TIMEOUT)) { | |
916 LOG(LS_WARNING) << "Received a data packet on a timed-out Connection. " | |
917 << "Resetting state to STATE_WRITE_INIT."; | |
918 set_write_state(STATE_WRITE_INIT); | |
919 } | |
920 } else { | |
921 // Not readable means the remote address hasn't sent a valid | |
922 // binding request yet. | |
923 | |
924 LOG_J(LS_WARNING, this) | |
925 << "Received non-STUN packet from an unreadable connection."; | |
926 } | 916 } |
927 } else if (!msg) { | 917 } else if (!msg) { |
928 // The packet was STUN, but failed a check and was handled internally. | 918 // The packet was STUN, but failed a check and was handled internally. |
929 } else { | 919 } else { |
930 // The packet is STUN and passed the Port checks. | 920 // The packet is STUN and passed the Port checks. |
931 // Perform our own checks to ensure this packet is valid. | 921 // Perform our own checks to ensure this packet is valid. |
932 // If this is a STUN request, then update the readable bit and respond. | 922 // If this is a STUN request, then update the readable bit and respond. |
933 // If this is a STUN response, then update the writable bit. | 923 // If this is a STUN response, then update the writable bit. |
934 // Log at LS_INFO if we receive a ping on an unwritable connection. | 924 // Log at LS_INFO if we receive a ping on an unwritable connection. |
935 rtc::LoggingSeverity sev = (!writable() ? rtc::LS_INFO : rtc::LS_VERBOSE); | 925 rtc::LoggingSeverity sev = (!writable() ? rtc::LS_INFO : rtc::LS_VERBOSE); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
985 requests_.CheckResponse(msg.get()); | 975 requests_.CheckResponse(msg.get()); |
986 } | 976 } |
987 // Otherwise silently discard the response message. | 977 // Otherwise silently discard the response message. |
988 break; | 978 break; |
989 | 979 |
990 // Remote end point sent an STUN indication instead of regular | 980 // Remote end point sent an STUN indication instead of regular |
991 // binding request. In this case |last_ping_received_| will be updated. | 981 // binding request. In this case |last_ping_received_| will be updated. |
992 // Otherwise we can mark connection to read timeout. No response will be | 982 // Otherwise we can mark connection to read timeout. No response will be |
993 // sent in this scenario. | 983 // sent in this scenario. |
994 case STUN_BINDING_INDICATION: | 984 case STUN_BINDING_INDICATION: |
995 if (read_state_ == STATE_READABLE) { | 985 ReceivedPing(); |
996 ReceivedPing(); | |
997 } else { | |
998 LOG_J(LS_WARNING, this) << "Received STUN binding indication " | |
999 << "from an unreadable connection."; | |
1000 } | |
1001 break; | 986 break; |
1002 | 987 |
1003 default: | 988 default: |
1004 ASSERT(false); | 989 ASSERT(false); |
1005 break; | 990 break; |
1006 } | 991 } |
1007 } | 992 } |
1008 } | 993 } |
1009 | 994 |
1010 void Connection::OnReadyToSend() { | 995 void Connection::OnReadyToSend() { |
1011 if (write_state_ == STATE_WRITABLE) { | 996 if (write_state_ == STATE_WRITABLE) { |
1012 SignalReadyToSend(this); | 997 SignalReadyToSend(this); |
1013 } | 998 } |
1014 } | 999 } |
1015 | 1000 |
1016 void Connection::Prune() { | 1001 void Connection::Prune() { |
1017 if (!pruned_) { | 1002 if (!pruned_) { |
1018 LOG_J(LS_VERBOSE, this) << "Connection pruned"; | 1003 LOG_J(LS_VERBOSE, this) << "Connection pruned"; |
1019 pruned_ = true; | 1004 pruned_ = true; |
1020 requests_.Clear(); | 1005 requests_.Clear(); |
1021 set_write_state(STATE_WRITE_TIMEOUT); | 1006 set_write_state(STATE_WRITE_TIMEOUT); |
1022 } | 1007 } |
1023 } | 1008 } |
1024 | 1009 |
1025 void Connection::Destroy() { | 1010 void Connection::Destroy() { |
1026 LOG_J(LS_VERBOSE, this) << "Connection destroyed"; | 1011 LOG_J(LS_VERBOSE, this) << "Connection destroyed"; |
1027 set_read_state(STATE_READ_TIMEOUT); | 1012 port_->thread()->Post(this, MSG_DELETE); |
1028 set_write_state(STATE_WRITE_TIMEOUT); | |
1029 } | 1013 } |
1030 | 1014 |
1031 void Connection::PrintPingsSinceLastResponse(std::string* s, size_t max) { | 1015 void Connection::PrintPingsSinceLastResponse(std::string* s, size_t max) { |
1032 std::ostringstream oss; | 1016 std::ostringstream oss; |
1033 oss << std::boolalpha; | 1017 oss << std::boolalpha; |
1034 if (pings_since_last_response_.size() > max) { | 1018 if (pings_since_last_response_.size() > max) { |
1035 for (size_t i = 0; i < max; i++) { | 1019 for (size_t i = 0; i < max; i++) { |
1036 const SentPing& ping = pings_since_last_response_[i]; | 1020 const SentPing& ping = pings_since_last_response_[i]; |
1037 oss << rtc::hex_encode(ping.id) << " "; | 1021 oss << rtc::hex_encode(ping.id) << " "; |
1038 } | 1022 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1082 << " ping failures and " | 1066 << " ping failures and " |
1083 << now - pings_since_last_response_[0].sent_time | 1067 << now - pings_since_last_response_[0].sent_time |
1084 << " ms without a response," | 1068 << " ms without a response," |
1085 << " ms since last received ping=" | 1069 << " ms since last received ping=" |
1086 << now - last_ping_received_ | 1070 << now - last_ping_received_ |
1087 << " ms since last received data=" | 1071 << " ms since last received data=" |
1088 << now - last_data_received_ | 1072 << now - last_data_received_ |
1089 << " rtt=" << rtt; | 1073 << " rtt=" << rtt; |
1090 set_write_state(STATE_WRITE_UNRELIABLE); | 1074 set_write_state(STATE_WRITE_UNRELIABLE); |
1091 } | 1075 } |
1092 | |
1093 if ((write_state_ == STATE_WRITE_UNRELIABLE || | 1076 if ((write_state_ == STATE_WRITE_UNRELIABLE || |
1094 write_state_ == STATE_WRITE_INIT) && | 1077 write_state_ == STATE_WRITE_INIT) && |
1095 TooLongWithoutResponse(pings_since_last_response_, | 1078 TooLongWithoutResponse(pings_since_last_response_, |
1096 CONNECTION_WRITE_TIMEOUT, | 1079 CONNECTION_WRITE_TIMEOUT, |
1097 now)) { | 1080 now)) { |
1098 LOG_J(LS_INFO, this) << "Timed out after " | 1081 LOG_J(LS_INFO, this) << "Timed out after " |
1099 << now - pings_since_last_response_[0].sent_time | 1082 << now - pings_since_last_response_[0].sent_time |
1100 << " ms without a response" | 1083 << " ms without a response" |
1101 << ", rtt=" << rtt; | 1084 << ", rtt=" << rtt; |
1102 set_write_state(STATE_WRITE_TIMEOUT); | 1085 set_write_state(STATE_WRITE_TIMEOUT); |
1103 } | 1086 } |
| 1087 |
| 1088 // Check the receiving state. |
| 1089 uint32 last_recv_time = last_received(); |
| 1090 bool receiving = now <= last_recv_time + receiving_timeout_; |
| 1091 set_receiving(receiving); |
1104 } | 1092 } |
1105 | 1093 |
1106 void Connection::Ping(uint32 now) { | 1094 void Connection::Ping(uint32 now) { |
1107 last_ping_sent_ = now; | 1095 last_ping_sent_ = now; |
1108 ConnectionRequest *req = new ConnectionRequest(this); | 1096 ConnectionRequest *req = new ConnectionRequest(this); |
1109 pings_since_last_response_.push_back(SentPing(req->id(), now)); | 1097 pings_since_last_response_.push_back(SentPing(req->id(), now)); |
1110 LOG_J(LS_VERBOSE, this) << "Sending STUN ping " | 1098 LOG_J(LS_VERBOSE, this) << "Sending STUN ping " |
1111 << ", id=" << rtc::hex_encode(req->id()); | 1099 << ", id=" << rtc::hex_encode(req->id()); |
1112 requests_.Send(req); | 1100 requests_.Send(req); |
1113 state_ = STATE_INPROGRESS; | 1101 state_ = STATE_INPROGRESS; |
1114 } | 1102 } |
1115 | 1103 |
1116 void Connection::ReceivedPing() { | 1104 void Connection::ReceivedPing() { |
| 1105 set_receiving(true); |
1117 last_ping_received_ = rtc::Time(); | 1106 last_ping_received_ = rtc::Time(); |
1118 set_read_state(STATE_READABLE); | |
1119 } | 1107 } |
1120 | 1108 |
1121 void Connection::ReceivedPingResponse() { | 1109 void Connection::ReceivedPingResponse() { |
1122 // We've already validated that this is a STUN binding response with | 1110 // We've already validated that this is a STUN binding response with |
1123 // the correct local and remote username for this connection. | 1111 // the correct local and remote username for this connection. |
1124 // So if we're not already, become writable. We may be bringing a pruned | 1112 // So if we're not already, become writable. We may be bringing a pruned |
1125 // connection back to life, but if we don't really want it, we can always | 1113 // connection back to life, but if we don't really want it, we can always |
1126 // prune it again. | 1114 // prune it again. |
| 1115 set_receiving(true); |
1127 set_write_state(STATE_WRITABLE); | 1116 set_write_state(STATE_WRITABLE); |
1128 set_state(STATE_SUCCEEDED); | 1117 set_state(STATE_SUCCEEDED); |
1129 pings_since_last_response_.clear(); | 1118 pings_since_last_response_.clear(); |
1130 last_ping_response_received_ = rtc::Time(); | 1119 last_ping_response_received_ = rtc::Time(); |
1131 } | 1120 } |
1132 | 1121 |
1133 std::string Connection::ToDebugId() const { | 1122 std::string Connection::ToDebugId() const { |
1134 std::stringstream ss; | 1123 std::stringstream ss; |
1135 ss << std::hex << this; | 1124 ss << std::hex << this; |
1136 return ss.str(); | 1125 return ss.str(); |
1137 } | 1126 } |
1138 | 1127 |
1139 std::string Connection::ToString() const { | 1128 std::string Connection::ToString() const { |
1140 const char CONNECT_STATE_ABBREV[2] = { | 1129 const char CONNECT_STATE_ABBREV[2] = { |
1141 '-', // not connected (false) | 1130 '-', // not connected (false) |
1142 'C', // connected (true) | 1131 'C', // connected (true) |
1143 }; | 1132 }; |
1144 const char READ_STATE_ABBREV[3] = { | 1133 const char RECEIVE_STATE_ABBREV[2] = { |
1145 '-', // STATE_READ_INIT | 1134 '-', // not receiving (false) |
1146 'R', // STATE_READABLE | 1135 'R', // receiving (true) |
1147 'x', // STATE_READ_TIMEOUT | |
1148 }; | 1136 }; |
1149 const char WRITE_STATE_ABBREV[4] = { | 1137 const char WRITE_STATE_ABBREV[4] = { |
1150 'W', // STATE_WRITABLE | 1138 'W', // STATE_WRITABLE |
1151 'w', // STATE_WRITE_UNRELIABLE | 1139 'w', // STATE_WRITE_UNRELIABLE |
1152 '-', // STATE_WRITE_INIT | 1140 '-', // STATE_WRITE_INIT |
1153 'x', // STATE_WRITE_TIMEOUT | 1141 'x', // STATE_WRITE_TIMEOUT |
1154 }; | 1142 }; |
1155 const std::string ICESTATE[4] = { | 1143 const std::string ICESTATE[4] = { |
1156 "W", // STATE_WAITING | 1144 "W", // STATE_WAITING |
1157 "I", // STATE_INPROGRESS | 1145 "I", // STATE_INPROGRESS |
1158 "S", // STATE_SUCCEEDED | 1146 "S", // STATE_SUCCEEDED |
1159 "F" // STATE_FAILED | 1147 "F" // STATE_FAILED |
1160 }; | 1148 }; |
1161 const Candidate& local = local_candidate(); | 1149 const Candidate& local = local_candidate(); |
1162 const Candidate& remote = remote_candidate(); | 1150 const Candidate& remote = remote_candidate(); |
1163 std::stringstream ss; | 1151 std::stringstream ss; |
1164 ss << "Conn[" << ToDebugId() | 1152 ss << "Conn[" << ToDebugId() |
1165 << ":" << port_->content_name() | 1153 << ":" << port_->content_name() |
1166 << ":" << local.id() << ":" << local.component() | 1154 << ":" << local.id() << ":" << local.component() |
1167 << ":" << local.generation() | 1155 << ":" << local.generation() |
1168 << ":" << local.type() << ":" << local.protocol() | 1156 << ":" << local.type() << ":" << local.protocol() |
1169 << ":" << local.address().ToSensitiveString() | 1157 << ":" << local.address().ToSensitiveString() |
1170 << "->" << remote.id() << ":" << remote.component() | 1158 << "->" << remote.id() << ":" << remote.component() |
1171 << ":" << remote.priority() | 1159 << ":" << remote.priority() |
1172 << ":" << remote.type() << ":" | 1160 << ":" << remote.type() << ":" |
1173 << remote.protocol() << ":" << remote.address().ToSensitiveString() << "|" | 1161 << remote.protocol() << ":" << remote.address().ToSensitiveString() << "|" |
1174 << CONNECT_STATE_ABBREV[connected()] | 1162 << CONNECT_STATE_ABBREV[connected()] |
1175 << READ_STATE_ABBREV[read_state()] | 1163 << RECEIVE_STATE_ABBREV[receiving()] |
1176 << WRITE_STATE_ABBREV[write_state()] | 1164 << WRITE_STATE_ABBREV[write_state()] |
1177 << ICESTATE[state()] << "|" | 1165 << ICESTATE[state()] << "|" |
1178 << priority() << "|"; | 1166 << priority() << "|"; |
1179 if (rtt_ < DEFAULT_RTT) { | 1167 if (rtt_ < DEFAULT_RTT) { |
1180 ss << rtt_ << "]"; | 1168 ss << rtt_ << "]"; |
1181 } else { | 1169 } else { |
1182 ss << "-]"; | 1170 ss << "-]"; |
1183 } | 1171 } |
1184 return ss.str(); | 1172 return ss.str(); |
1185 } | 1173 } |
1186 | 1174 |
1187 std::string Connection::ToSensitiveString() const { | 1175 std::string Connection::ToSensitiveString() const { |
1188 return ToString(); | 1176 return ToString(); |
1189 } | 1177 } |
1190 | 1178 |
1191 void Connection::OnConnectionRequestResponse(ConnectionRequest* request, | 1179 void Connection::OnConnectionRequestResponse(ConnectionRequest* request, |
1192 StunMessage* response) { | 1180 StunMessage* response) { |
1193 // Log at LS_INFO if we receive a ping response on an unwritable | 1181 // Log at LS_INFO if we receive a ping response on an unwritable |
1194 // connection. | 1182 // connection. |
1195 rtc::LoggingSeverity sev = !writable() ? rtc::LS_INFO : rtc::LS_VERBOSE; | 1183 rtc::LoggingSeverity sev = !writable() ? rtc::LS_INFO : rtc::LS_VERBOSE; |
1196 | 1184 |
1197 uint32 rtt = request->Elapsed(); | 1185 uint32 rtt = request->Elapsed(); |
1198 | 1186 |
1199 ReceivedPingResponse(); | 1187 ReceivedPingResponse(); |
1200 if (remote_ice_mode_ == ICEMODE_LITE) { | |
1201 // A ice-lite end point never initiates ping requests. This will allow | |
1202 // us to move to STATE_READABLE without an incoming ping request. | |
1203 set_read_state(STATE_READABLE); | |
1204 } | |
1205 | 1188 |
1206 if (LOG_CHECK_LEVEL_V(sev)) { | 1189 if (LOG_CHECK_LEVEL_V(sev)) { |
1207 bool use_candidate = ( | 1190 bool use_candidate = ( |
1208 response->GetByteString(STUN_ATTR_USE_CANDIDATE) != nullptr); | 1191 response->GetByteString(STUN_ATTR_USE_CANDIDATE) != nullptr); |
1209 std::string pings; | 1192 std::string pings; |
1210 PrintPingsSinceLastResponse(&pings, 5); | 1193 PrintPingsSinceLastResponse(&pings, 5); |
1211 LOG_JV(sev, this) << "Received STUN ping response" | 1194 LOG_JV(sev, this) << "Received STUN ping response" |
1212 << ", id=" << rtc::hex_encode(request->id()) | 1195 << ", id=" << rtc::hex_encode(request->id()) |
1213 << ", code=0" // Makes logging easier to parse. | 1196 << ", code=0" // Makes logging easier to parse. |
1214 << ", rtt=" << rtt | 1197 << ", rtt=" << rtt |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1262 void Connection::OnConnectionRequestSent(ConnectionRequest* request) { | 1245 void Connection::OnConnectionRequestSent(ConnectionRequest* request) { |
1263 // Log at LS_INFO if we send a ping on an unwritable connection. | 1246 // Log at LS_INFO if we send a ping on an unwritable connection. |
1264 rtc::LoggingSeverity sev = !writable() ? rtc::LS_INFO : rtc::LS_VERBOSE; | 1247 rtc::LoggingSeverity sev = !writable() ? rtc::LS_INFO : rtc::LS_VERBOSE; |
1265 bool use_candidate = use_candidate_attr(); | 1248 bool use_candidate = use_candidate_attr(); |
1266 LOG_JV(sev, this) << "Sent STUN ping" | 1249 LOG_JV(sev, this) << "Sent STUN ping" |
1267 << ", id=" << rtc::hex_encode(request->id()) | 1250 << ", id=" << rtc::hex_encode(request->id()) |
1268 << ", use_candidate=" << use_candidate; | 1251 << ", use_candidate=" << use_candidate; |
1269 } | 1252 } |
1270 | 1253 |
1271 void Connection::CheckTimeout() { | 1254 void Connection::CheckTimeout() { |
1272 // If both read and write have timed out or read has never initialized, then | 1255 // If write has timed out and it is not receiving, remove the connection. |
1273 // this connection can contribute no more to p2p socket unless at some later | 1256 if (!receiving_ && write_state_ == STATE_WRITE_TIMEOUT) { |
1274 // date readability were to come back. However, we gave readability a long | |
1275 // time to timeout, so at this point, it seems fair to get rid of this | |
1276 // connection. | |
1277 if ((read_state_ == STATE_READ_TIMEOUT || | |
1278 read_state_ == STATE_READ_INIT) && | |
1279 write_state_ == STATE_WRITE_TIMEOUT) { | |
1280 port_->thread()->Post(this, MSG_DELETE); | 1257 port_->thread()->Post(this, MSG_DELETE); |
1281 } | 1258 } |
1282 } | 1259 } |
1283 | 1260 |
1284 void Connection::HandleRoleConflictFromPeer() { | 1261 void Connection::HandleRoleConflictFromPeer() { |
1285 port_->SignalRoleConflict(port_); | 1262 port_->SignalRoleConflict(port_); |
1286 } | 1263 } |
1287 | 1264 |
1288 void Connection::MaybeSetRemoteIceCredentials(const std::string& ice_ufrag, | 1265 void Connection::MaybeSetRemoteIceCredentials(const std::string& ice_ufrag, |
1289 const std::string& ice_pwd) { | 1266 const std::string& ice_pwd) { |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1425 ASSERT(sent < 0); | 1402 ASSERT(sent < 0); |
1426 error_ = port_->GetError(); | 1403 error_ = port_->GetError(); |
1427 sent_packets_discarded_++; | 1404 sent_packets_discarded_++; |
1428 } else { | 1405 } else { |
1429 send_rate_tracker_.AddSamples(sent); | 1406 send_rate_tracker_.AddSamples(sent); |
1430 } | 1407 } |
1431 return sent; | 1408 return sent; |
1432 } | 1409 } |
1433 | 1410 |
1434 } // namespace cricket | 1411 } // namespace cricket |
OLD | NEW |