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

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

Powered by Google App Engine
This is Rietveld 408576698