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

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

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

Powered by Google App Engine
This is Rietveld 408576698