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 sent_packets_discarded_(0), | 798 sent_packets_discarded_(0), |
799 sent_packets_total_(0), | 799 sent_packets_total_(0), |
800 reported_(false), | 800 reported_(false), |
801 state_(STATE_WAITING) { | 801 state_(STATE_WAITING), |
802 receiving_timeout_(CONNECTION_RECEIVE_SHORT_TIMEOUT) { | |
802 // All of our connections start in WAITING state. | 803 // All of our connections start in WAITING state. |
803 // TODO(mallinath) - Start connections from STATE_FROZEN. | 804 // TODO(mallinath) - Start connections from STATE_FROZEN. |
804 // Wire up to send stun packets | 805 // Wire up to send stun packets |
805 requests_.SignalSendPacket.connect(this, &Connection::OnSendStunPacket); | 806 requests_.SignalSendPacket.connect(this, &Connection::OnSendStunPacket); |
806 LOG_J(LS_INFO, this) << "Connection created"; | 807 LOG_J(LS_INFO, this) << "Connection created"; |
807 } | 808 } |
808 | 809 |
809 Connection::~Connection() { | 810 Connection::~Connection() { |
810 } | 811 } |
811 | 812 |
(...skipping 20 matching lines...) Expand all Loading... | |
832 g = remote_candidate_.priority(); | 833 g = remote_candidate_.priority(); |
833 d = local_candidate().priority(); | 834 d = local_candidate().priority(); |
834 } | 835 } |
835 priority = std::min(g, d); | 836 priority = std::min(g, d); |
836 priority = priority << 32; | 837 priority = priority << 32; |
837 priority += 2 * std::max(g, d) + (g > d ? 1 : 0); | 838 priority += 2 * std::max(g, d) + (g > d ? 1 : 0); |
838 } | 839 } |
839 return priority; | 840 return priority; |
840 } | 841 } |
841 | 842 |
842 void Connection::set_read_state(ReadState value) { | |
843 ReadState old_value = read_state_; | |
844 read_state_ = value; | |
845 if (value != old_value) { | |
846 LOG_J(LS_VERBOSE, this) << "set_read_state"; | |
847 SignalStateChange(this); | |
848 CheckTimeout(); | |
849 } | |
850 } | |
851 | |
852 void Connection::set_write_state(WriteState value) { | 843 void Connection::set_write_state(WriteState value) { |
853 WriteState old_value = write_state_; | 844 WriteState old_value = write_state_; |
854 write_state_ = value; | 845 write_state_ = value; |
855 if (value != old_value) { | 846 if (value != old_value) { |
856 LOG_J(LS_VERBOSE, this) << "set_write_state from: " << old_value << " to " | 847 LOG_J(LS_VERBOSE, this) << "set_write_state from: " << old_value << " to " |
857 << value; | 848 << value; |
858 SignalStateChange(this); | 849 SignalStateChange(this); |
859 CheckTimeout(); | |
860 } | 850 } |
861 } | 851 } |
862 | 852 |
853 void Connection::set_receiving(bool value) { | |
854 if (value != receiving_) { | |
855 LOG_J(LS_VERBOSE, this) << "set_receiving to " << value; | |
856 receiving_ = value; | |
857 SignalStateChange(this); | |
858 } | |
859 } | |
860 | |
863 void Connection::set_state(State state) { | 861 void Connection::set_state(State state) { |
864 State old_state = state_; | 862 State old_state = state_; |
865 state_ = state; | 863 state_ = state; |
866 if (state != old_state) { | 864 if (state != old_state) { |
867 LOG_J(LS_VERBOSE, this) << "set_state"; | 865 LOG_J(LS_VERBOSE, this) << "set_state"; |
868 } | 866 } |
869 } | 867 } |
870 | 868 |
871 void Connection::set_connected(bool value) { | 869 void Connection::set_connected(bool value) { |
872 bool old_value = connected_; | 870 bool old_value = connected_; |
(...skipping 21 matching lines...) Expand all Loading... | |
894 } | 892 } |
895 | 893 |
896 void Connection::OnReadPacket( | 894 void Connection::OnReadPacket( |
897 const char* data, size_t size, const rtc::PacketTime& packet_time) { | 895 const char* data, size_t size, const rtc::PacketTime& packet_time) { |
898 rtc::scoped_ptr<IceMessage> msg; | 896 rtc::scoped_ptr<IceMessage> msg; |
899 std::string remote_ufrag; | 897 std::string remote_ufrag; |
900 const rtc::SocketAddress& addr(remote_candidate_.address()); | 898 const rtc::SocketAddress& addr(remote_candidate_.address()); |
901 if (!port_->GetStunMessage(data, size, addr, msg.accept(), &remote_ufrag)) { | 899 if (!port_->GetStunMessage(data, size, addr, msg.accept(), &remote_ufrag)) { |
902 // The packet did not parse as a valid STUN message | 900 // The packet did not parse as a valid STUN message |
903 | 901 |
904 // If this connection is readable, then pass along the packet. | 902 // If this connection received ping before, then pass along the packet. |
pthatcher1
2015/09/17 05:58:42
received ping => receive a ping
honghaiz3
2015/09/17 19:47:56
Done.
| |
905 if (read_state_ == STATE_READABLE) { | 903 // If the remote side is ICE-LITE, it may never receive ping, but it needs |
pthatcher1
2015/09/17 05:58:42
receive ping => receive a ping
honghaiz3
2015/09/17 19:47:56
Done.
| |
904 // to receive ping response before receiving data packet. | |
pthatcher1
2015/09/17 05:58:42
receive ping => receive a ping
receive data packet
honghaiz3
2015/09/17 19:47:56
Done.
| |
905 if (last_ping_received_ != 0 || last_ping_response_received_) { | |
pthatcher1
2015/09/17 05:58:42
I don't understand why we even bother to check the
honghaiz3
2015/09/17 19:47:56
Yes the primary purpose is to make it have the sam
| |
906 // readable means data from this address is acceptable | 906 // readable means data from this address is acceptable |
907 // Send it on! | 907 // Send it on! |
908 last_data_received_ = rtc::Time(); | 908 last_data_received_ = rtc::Time(); |
909 recv_rate_tracker_.Update(size); | 909 recv_rate_tracker_.Update(size); |
910 SignalReadPacket(this, data, size, packet_time); | 910 SignalReadPacket(this, data, size, packet_time); |
911 | 911 |
912 // If timed out sending writability checks, start up again | 912 // If timed out sending writability checks, start up again |
913 if (!pruned_ && (write_state_ == STATE_WRITE_TIMEOUT)) { | 913 if (!pruned_ && (write_state_ == STATE_WRITE_TIMEOUT)) { |
914 LOG(LS_WARNING) << "Received a data packet on a timed-out Connection. " | 914 LOG(LS_WARNING) << "Received a data packet on a timed-out Connection. " |
915 << "Resetting state to STATE_WRITE_INIT."; | 915 << "Resetting state to STATE_WRITE_INIT."; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
983 requests_.CheckResponse(msg.get()); | 983 requests_.CheckResponse(msg.get()); |
984 } | 984 } |
985 // Otherwise silently discard the response message. | 985 // Otherwise silently discard the response message. |
986 break; | 986 break; |
987 | 987 |
988 // Remote end point sent an STUN indication instead of regular | 988 // Remote end point sent an STUN indication instead of regular |
989 // binding request. In this case |last_ping_received_| will be updated. | 989 // binding request. In this case |last_ping_received_| will be updated. |
990 // Otherwise we can mark connection to read timeout. No response will be | 990 // Otherwise we can mark connection to read timeout. No response will be |
991 // sent in this scenario. | 991 // sent in this scenario. |
992 case STUN_BINDING_INDICATION: | 992 case STUN_BINDING_INDICATION: |
993 if (read_state_ == STATE_READABLE) { | 993 ReceivedPing(); |
994 ReceivedPing(); | |
995 } else { | |
996 LOG_J(LS_WARNING, this) << "Received STUN binding indication " | |
997 << "from an unreadable connection."; | |
998 } | |
999 break; | 994 break; |
1000 | 995 |
1001 default: | 996 default: |
1002 ASSERT(false); | 997 ASSERT(false); |
1003 break; | 998 break; |
1004 } | 999 } |
1005 } | 1000 } |
1006 } | 1001 } |
1007 | 1002 |
1008 void Connection::OnReadyToSend() { | 1003 void Connection::OnReadyToSend() { |
1009 if (write_state_ == STATE_WRITABLE) { | 1004 if (write_state_ == STATE_WRITABLE) { |
1010 SignalReadyToSend(this); | 1005 SignalReadyToSend(this); |
1011 } | 1006 } |
1012 } | 1007 } |
1013 | 1008 |
1014 void Connection::Prune() { | 1009 void Connection::Prune() { |
1015 if (!pruned_) { | 1010 if (!pruned_) { |
1016 LOG_J(LS_VERBOSE, this) << "Connection pruned"; | 1011 LOG_J(LS_VERBOSE, this) << "Connection pruned"; |
1017 pruned_ = true; | 1012 pruned_ = true; |
1018 requests_.Clear(); | 1013 requests_.Clear(); |
pthatcher1
2015/09/17 05:58:42
There's a lot going on in one CL. Could we break
honghaiz3
2015/09/17 19:47:56
It is kind of convoluted. I created a new CL only
| |
1019 set_write_state(STATE_WRITE_TIMEOUT); | |
1020 } | 1014 } |
1021 } | 1015 } |
1022 | 1016 |
1023 void Connection::Destroy() { | 1017 void Connection::Destroy() { |
1024 LOG_J(LS_VERBOSE, this) << "Connection destroyed"; | 1018 LOG_J(LS_VERBOSE, this) << "Connection destroyed"; |
1025 set_read_state(STATE_READ_TIMEOUT); | 1019 port_->thread()->Post(this, MSG_DELETE); |
1026 set_write_state(STATE_WRITE_TIMEOUT); | |
1027 } | 1020 } |
1028 | 1021 |
1029 void Connection::PrintPingsSinceLastResponse(std::string* s, size_t max) { | 1022 void Connection::PrintPingsSinceLastResponse(std::string* s, size_t max) { |
1030 std::ostringstream oss; | 1023 std::ostringstream oss; |
1031 oss << std::boolalpha; | 1024 oss << std::boolalpha; |
1032 if (pings_since_last_response_.size() > max) { | 1025 if (pings_since_last_response_.size() > max) { |
1033 for (size_t i = 0; i < max; i++) { | 1026 for (size_t i = 0; i < max; i++) { |
1034 const SentPing& ping = pings_since_last_response_[i]; | 1027 const SentPing& ping = pings_since_last_response_[i]; |
1035 oss << rtc::hex_encode(ping.id) << " "; | 1028 oss << rtc::hex_encode(ping.id) << " "; |
1036 } | 1029 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1092 write_state_ == STATE_WRITE_INIT) && | 1085 write_state_ == STATE_WRITE_INIT) && |
1093 TooLongWithoutResponse(pings_since_last_response_, | 1086 TooLongWithoutResponse(pings_since_last_response_, |
1094 CONNECTION_WRITE_TIMEOUT, | 1087 CONNECTION_WRITE_TIMEOUT, |
1095 now)) { | 1088 now)) { |
1096 LOG_J(LS_INFO, this) << "Timed out after " | 1089 LOG_J(LS_INFO, this) << "Timed out after " |
1097 << now - pings_since_last_response_[0].sent_time | 1090 << now - pings_since_last_response_[0].sent_time |
1098 << " ms without a response" | 1091 << " ms without a response" |
1099 << ", rtt=" << rtt; | 1092 << ", rtt=" << rtt; |
1100 set_write_state(STATE_WRITE_TIMEOUT); | 1093 set_write_state(STATE_WRITE_TIMEOUT); |
1101 } | 1094 } |
1095 | |
1096 // Check the receiving state. | |
1097 uint32 last_recv_time = last_received(); | |
pthatcher1
2015/09/17 05:58:42
Might make sense to write it as:
uint32 time_sinc
honghaiz3
2015/09/17 19:47:56
This saved an operation. But using subtraction on
| |
1098 if (receiving_) { | |
1099 if (now > last_recv_time + receiving_timeout_) { | |
1100 set_receiving(false); | |
1101 } | |
1102 } else if (now > last_recv_time + CONNECTION_RECEIVE_LONG_TIMEOUT) { | |
1103 // Delete self. | |
1104 Destroy(); | |
1105 } | |
1102 } | 1106 } |
1103 | 1107 |
1104 void Connection::Ping(uint32 now) { | 1108 void Connection::Ping(uint32 now) { |
1105 last_ping_sent_ = now; | 1109 last_ping_sent_ = now; |
1106 ConnectionRequest *req = new ConnectionRequest(this); | 1110 ConnectionRequest *req = new ConnectionRequest(this); |
1107 pings_since_last_response_.push_back(SentPing(req->id(), now)); | 1111 pings_since_last_response_.push_back(SentPing(req->id(), now)); |
1108 LOG_J(LS_VERBOSE, this) << "Sending STUN ping " | 1112 LOG_J(LS_VERBOSE, this) << "Sending STUN ping " |
1109 << ", id=" << rtc::hex_encode(req->id()); | 1113 << ", id=" << rtc::hex_encode(req->id()); |
1110 requests_.Send(req); | 1114 requests_.Send(req); |
1111 state_ = STATE_INPROGRESS; | 1115 state_ = STATE_INPROGRESS; |
1112 } | 1116 } |
1113 | 1117 |
1114 void Connection::ReceivedPing() { | 1118 void Connection::ReceivedPing() { |
1115 last_ping_received_ = rtc::Time(); | 1119 last_ping_received_ = rtc::Time(); |
1116 set_read_state(STATE_READABLE); | |
1117 } | 1120 } |
1118 | 1121 |
1119 void Connection::ReceivedPingResponse() { | 1122 void Connection::ReceivedPingResponse() { |
1120 // We've already validated that this is a STUN binding response with | 1123 // We've already validated that this is a STUN binding response with |
1121 // the correct local and remote username for this connection. | 1124 // the correct local and remote username for this connection. |
1122 // So if we're not already, become writable. We may be bringing a pruned | 1125 // So if we're not already, become writable. We may be bringing a pruned |
1123 // connection back to life, but if we don't really want it, we can always | 1126 // connection back to life, but if we don't really want it, we can always |
1124 // prune it again. | 1127 // prune it again. |
1125 set_write_state(STATE_WRITABLE); | 1128 set_write_state(STATE_WRITABLE); |
1126 set_state(STATE_SUCCEEDED); | 1129 set_state(STATE_SUCCEEDED); |
1127 pings_since_last_response_.clear(); | 1130 pings_since_last_response_.clear(); |
1128 last_ping_response_received_ = rtc::Time(); | 1131 last_ping_response_received_ = rtc::Time(); |
1129 } | 1132 } |
1130 | 1133 |
1131 std::string Connection::ToDebugId() const { | 1134 std::string Connection::ToDebugId() const { |
1132 std::stringstream ss; | 1135 std::stringstream ss; |
1133 ss << std::hex << this; | 1136 ss << std::hex << this; |
1134 return ss.str(); | 1137 return ss.str(); |
1135 } | 1138 } |
1136 | 1139 |
1137 std::string Connection::ToString() const { | 1140 std::string Connection::ToString() const { |
1138 const char CONNECT_STATE_ABBREV[2] = { | 1141 const char CONNECT_STATE_ABBREV[2] = { |
1139 '-', // not connected (false) | 1142 '-', // not connected (false) |
1140 'C', // connected (true) | 1143 'C', // connected (true) |
1141 }; | 1144 }; |
1142 const char READ_STATE_ABBREV[3] = { | 1145 const char RECEIVE_STATE_ABBREV[2] = { |
1143 '-', // STATE_READ_INIT | 1146 '-', // not receiving (false) |
1144 'R', // STATE_READABLE | 1147 'R', // receiving (true) |
1145 'x', // STATE_READ_TIMEOUT | |
1146 }; | 1148 }; |
1147 const char WRITE_STATE_ABBREV[4] = { | 1149 const char WRITE_STATE_ABBREV[4] = { |
1148 'W', // STATE_WRITABLE | 1150 'W', // STATE_WRITABLE |
1149 'w', // STATE_WRITE_UNRELIABLE | 1151 'w', // STATE_WRITE_UNRELIABLE |
1150 '-', // STATE_WRITE_INIT | 1152 '-', // STATE_WRITE_INIT |
1151 'x', // STATE_WRITE_TIMEOUT | 1153 'x', // STATE_WRITE_TIMEOUT |
1152 }; | 1154 }; |
1153 const std::string ICESTATE[4] = { | 1155 const std::string ICESTATE[4] = { |
1154 "W", // STATE_WAITING | 1156 "W", // STATE_WAITING |
1155 "I", // STATE_INPROGRESS | 1157 "I", // STATE_INPROGRESS |
1156 "S", // STATE_SUCCEEDED | 1158 "S", // STATE_SUCCEEDED |
1157 "F" // STATE_FAILED | 1159 "F" // STATE_FAILED |
1158 }; | 1160 }; |
1159 const Candidate& local = local_candidate(); | 1161 const Candidate& local = local_candidate(); |
1160 const Candidate& remote = remote_candidate(); | 1162 const Candidate& remote = remote_candidate(); |
1161 std::stringstream ss; | 1163 std::stringstream ss; |
1162 ss << "Conn[" << ToDebugId() | 1164 ss << "Conn[" << ToDebugId() |
1163 << ":" << port_->content_name() | 1165 << ":" << port_->content_name() |
1164 << ":" << local.id() << ":" << local.component() | 1166 << ":" << local.id() << ":" << local.component() |
1165 << ":" << local.generation() | 1167 << ":" << local.generation() |
1166 << ":" << local.type() << ":" << local.protocol() | 1168 << ":" << local.type() << ":" << local.protocol() |
1167 << ":" << local.address().ToSensitiveString() | 1169 << ":" << local.address().ToSensitiveString() |
1168 << "->" << remote.id() << ":" << remote.component() | 1170 << "->" << remote.id() << ":" << remote.component() |
1169 << ":" << remote.priority() | 1171 << ":" << remote.priority() |
1170 << ":" << remote.type() << ":" | 1172 << ":" << remote.type() << ":" |
1171 << remote.protocol() << ":" << remote.address().ToSensitiveString() << "|" | 1173 << remote.protocol() << ":" << remote.address().ToSensitiveString() << "|" |
1172 << CONNECT_STATE_ABBREV[connected()] | 1174 << CONNECT_STATE_ABBREV[connected()] |
1173 << READ_STATE_ABBREV[read_state()] | 1175 << RECEIVE_STATE_ABBREV[receiving()] |
1174 << WRITE_STATE_ABBREV[write_state()] | 1176 << WRITE_STATE_ABBREV[write_state()] |
1175 << ICESTATE[state()] << "|" | 1177 << ICESTATE[state()] << "|" |
1176 << priority() << "|"; | 1178 << priority() << "|"; |
1177 if (rtt_ < DEFAULT_RTT) { | 1179 if (rtt_ < DEFAULT_RTT) { |
1178 ss << rtt_ << "]"; | 1180 ss << rtt_ << "]"; |
1179 } else { | 1181 } else { |
1180 ss << "-]"; | 1182 ss << "-]"; |
1181 } | 1183 } |
1182 return ss.str(); | 1184 return ss.str(); |
1183 } | 1185 } |
1184 | 1186 |
1185 std::string Connection::ToSensitiveString() const { | 1187 std::string Connection::ToSensitiveString() const { |
1186 return ToString(); | 1188 return ToString(); |
1187 } | 1189 } |
1188 | 1190 |
1189 void Connection::OnConnectionRequestResponse(ConnectionRequest* request, | 1191 void Connection::OnConnectionRequestResponse(ConnectionRequest* request, |
1190 StunMessage* response) { | 1192 StunMessage* response) { |
1191 // Log at LS_INFO if we receive a ping response on an unwritable | 1193 // Log at LS_INFO if we receive a ping response on an unwritable |
1192 // connection. | 1194 // connection. |
1193 rtc::LoggingSeverity sev = !writable() ? rtc::LS_INFO : rtc::LS_VERBOSE; | 1195 rtc::LoggingSeverity sev = !writable() ? rtc::LS_INFO : rtc::LS_VERBOSE; |
1194 | 1196 |
1195 uint32 rtt = request->Elapsed(); | 1197 uint32 rtt = request->Elapsed(); |
1196 | 1198 |
1197 ReceivedPingResponse(); | 1199 ReceivedPingResponse(); |
1198 if (remote_ice_mode_ == ICEMODE_LITE) { | |
1199 // A ice-lite end point never initiates ping requests. This will allow | |
1200 // us to move to STATE_READABLE without an incoming ping request. | |
1201 set_read_state(STATE_READABLE); | |
1202 } | |
1203 | 1200 |
1204 if (LOG_CHECK_LEVEL_V(sev)) { | 1201 if (LOG_CHECK_LEVEL_V(sev)) { |
1205 bool use_candidate = ( | 1202 bool use_candidate = ( |
1206 response->GetByteString(STUN_ATTR_USE_CANDIDATE) != nullptr); | 1203 response->GetByteString(STUN_ATTR_USE_CANDIDATE) != nullptr); |
1207 std::string pings; | 1204 std::string pings; |
1208 PrintPingsSinceLastResponse(&pings, 5); | 1205 PrintPingsSinceLastResponse(&pings, 5); |
1209 LOG_JV(sev, this) << "Received STUN ping response" | 1206 LOG_JV(sev, this) << "Received STUN ping response" |
1210 << ", id=" << rtc::hex_encode(request->id()) | 1207 << ", id=" << rtc::hex_encode(request->id()) |
1211 << ", code=0" // Makes logging easier to parse. | 1208 << ", code=0" // Makes logging easier to parse. |
1212 << ", rtt=" << rtt | 1209 << ", rtt=" << rtt |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1259 | 1256 |
1260 void Connection::OnConnectionRequestSent(ConnectionRequest* request) { | 1257 void Connection::OnConnectionRequestSent(ConnectionRequest* request) { |
1261 // Log at LS_INFO if we send a ping on an unwritable connection. | 1258 // Log at LS_INFO if we send a ping on an unwritable connection. |
1262 rtc::LoggingSeverity sev = !writable() ? rtc::LS_INFO : rtc::LS_VERBOSE; | 1259 rtc::LoggingSeverity sev = !writable() ? rtc::LS_INFO : rtc::LS_VERBOSE; |
1263 bool use_candidate = use_candidate_attr(); | 1260 bool use_candidate = use_candidate_attr(); |
1264 LOG_JV(sev, this) << "Sent STUN ping" | 1261 LOG_JV(sev, this) << "Sent STUN ping" |
1265 << ", id=" << rtc::hex_encode(request->id()) | 1262 << ", id=" << rtc::hex_encode(request->id()) |
1266 << ", use_candidate=" << use_candidate; | 1263 << ", use_candidate=" << use_candidate; |
1267 } | 1264 } |
1268 | 1265 |
1269 void Connection::CheckTimeout() { | |
1270 // If both read and write have timed out or read has never initialized, then | |
1271 // this connection can contribute no more to p2p socket unless at some later | |
1272 // date readability were to come back. However, we gave readability a long | |
1273 // time to timeout, so at this point, it seems fair to get rid of this | |
1274 // connection. | |
1275 if ((read_state_ == STATE_READ_TIMEOUT || | |
1276 read_state_ == STATE_READ_INIT) && | |
1277 write_state_ == STATE_WRITE_TIMEOUT) { | |
1278 port_->thread()->Post(this, MSG_DELETE); | |
1279 } | |
1280 } | |
1281 | |
1282 void Connection::HandleRoleConflictFromPeer() { | 1266 void Connection::HandleRoleConflictFromPeer() { |
1283 port_->SignalRoleConflict(port_); | 1267 port_->SignalRoleConflict(port_); |
1284 } | 1268 } |
1285 | 1269 |
1286 void Connection::MaybeSetRemoteIceCredentials(const std::string& ice_ufrag, | 1270 void Connection::MaybeSetRemoteIceCredentials(const std::string& ice_ufrag, |
1287 const std::string& ice_pwd) { | 1271 const std::string& ice_pwd) { |
1288 if (remote_candidate_.username() == ice_ufrag && | 1272 if (remote_candidate_.username() == ice_ufrag && |
1289 remote_candidate_.password().empty()) { | 1273 remote_candidate_.password().empty()) { |
1290 remote_candidate_.set_password(ice_pwd); | 1274 remote_candidate_.set_password(ice_pwd); |
1291 } | 1275 } |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1423 ASSERT(sent < 0); | 1407 ASSERT(sent < 0); |
1424 error_ = port_->GetError(); | 1408 error_ = port_->GetError(); |
1425 sent_packets_discarded_++; | 1409 sent_packets_discarded_++; |
1426 } else { | 1410 } else { |
1427 send_rate_tracker_.Update(sent); | 1411 send_rate_tracker_.Update(sent); |
1428 } | 1412 } |
1429 return sent; | 1413 return sent; |
1430 } | 1414 } |
1431 | 1415 |
1432 } // namespace cricket | 1416 } // namespace cricket |
OLD | NEW |