OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/quic/chromium/quic_stream_factory.h" | 5 #include "net/quic/chromium/quic_stream_factory.h" |
6 | 6 |
7 #include <openssl/aead.h> | 7 #include <openssl/aead.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <tuple> | 10 #include <tuple> |
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 const std::string& user_agent_id, | 719 const std::string& user_agent_id, |
720 const QuicVersionVector& supported_versions, | 720 const QuicVersionVector& supported_versions, |
721 bool enable_port_selection, | 721 bool enable_port_selection, |
722 bool always_require_handshake_confirmation, | 722 bool always_require_handshake_confirmation, |
723 bool disable_connection_pooling, | 723 bool disable_connection_pooling, |
724 float load_server_info_timeout_srtt_multiplier, | 724 float load_server_info_timeout_srtt_multiplier, |
725 bool enable_connection_racing, | 725 bool enable_connection_racing, |
726 bool enable_non_blocking_io, | 726 bool enable_non_blocking_io, |
727 bool disable_disk_cache, | 727 bool disable_disk_cache, |
728 bool prefer_aes, | 728 bool prefer_aes, |
| 729 int max_number_of_lossy_connections, |
| 730 float packet_loss_threshold, |
| 731 int max_disabled_reasons, |
| 732 int threshold_public_resets_post_handshake, |
| 733 int threshold_timeouts_with_open_streams, |
729 int socket_receive_buffer_size, | 734 int socket_receive_buffer_size, |
730 bool delay_tcp_race, | 735 bool delay_tcp_race, |
731 int max_server_configs_stored_in_properties, | 736 int max_server_configs_stored_in_properties, |
732 bool close_sessions_on_ip_change, | 737 bool close_sessions_on_ip_change, |
733 bool disable_quic_on_timeout_with_open_streams, | 738 bool disable_quic_on_timeout_with_open_streams, |
734 int idle_connection_timeout_seconds, | 739 int idle_connection_timeout_seconds, |
735 int reduced_ping_timeout_seconds, | 740 int reduced_ping_timeout_seconds, |
736 int packet_reader_yield_after_duration_milliseconds, | 741 int packet_reader_yield_after_duration_milliseconds, |
737 bool migrate_sessions_on_network_change, | 742 bool migrate_sessions_on_network_change, |
738 bool migrate_sessions_early, | 743 bool migrate_sessions_early, |
(...skipping 26 matching lines...) Expand all Loading... |
765 enable_port_selection_(enable_port_selection), | 770 enable_port_selection_(enable_port_selection), |
766 always_require_handshake_confirmation_( | 771 always_require_handshake_confirmation_( |
767 always_require_handshake_confirmation), | 772 always_require_handshake_confirmation), |
768 disable_connection_pooling_(disable_connection_pooling), | 773 disable_connection_pooling_(disable_connection_pooling), |
769 load_server_info_timeout_srtt_multiplier_( | 774 load_server_info_timeout_srtt_multiplier_( |
770 load_server_info_timeout_srtt_multiplier), | 775 load_server_info_timeout_srtt_multiplier), |
771 enable_connection_racing_(enable_connection_racing), | 776 enable_connection_racing_(enable_connection_racing), |
772 enable_non_blocking_io_(enable_non_blocking_io), | 777 enable_non_blocking_io_(enable_non_blocking_io), |
773 disable_disk_cache_(disable_disk_cache), | 778 disable_disk_cache_(disable_disk_cache), |
774 prefer_aes_(prefer_aes), | 779 prefer_aes_(prefer_aes), |
775 disable_quic_on_timeout_with_open_streams_( | 780 max_number_of_lossy_connections_(max_number_of_lossy_connections), |
776 disable_quic_on_timeout_with_open_streams), | 781 packet_loss_threshold_(packet_loss_threshold), |
| 782 max_disabled_reasons_(max_disabled_reasons), |
| 783 num_public_resets_post_handshake_(0), |
| 784 num_timeouts_with_open_streams_(0), |
| 785 max_public_resets_post_handshake_(0), |
| 786 max_timeouts_with_open_streams_(0), |
| 787 threshold_timeouts_with_open_streams_( |
| 788 threshold_timeouts_with_open_streams), |
| 789 threshold_public_resets_post_handshake_( |
| 790 threshold_public_resets_post_handshake), |
777 socket_receive_buffer_size_(socket_receive_buffer_size), | 791 socket_receive_buffer_size_(socket_receive_buffer_size), |
778 delay_tcp_race_(delay_tcp_race), | 792 delay_tcp_race_(delay_tcp_race), |
779 ping_timeout_(QuicTime::Delta::FromSeconds(kPingTimeoutSecs)), | 793 ping_timeout_(QuicTime::Delta::FromSeconds(kPingTimeoutSecs)), |
780 reduced_ping_timeout_( | 794 reduced_ping_timeout_( |
781 QuicTime::Delta::FromSeconds(reduced_ping_timeout_seconds)), | 795 QuicTime::Delta::FromSeconds(reduced_ping_timeout_seconds)), |
782 yield_after_packets_(kQuicYieldAfterPacketsRead), | 796 yield_after_packets_(kQuicYieldAfterPacketsRead), |
783 yield_after_duration_(QuicTime::Delta::FromMilliseconds( | 797 yield_after_duration_(QuicTime::Delta::FromMilliseconds( |
784 packet_reader_yield_after_duration_milliseconds)), | 798 packet_reader_yield_after_duration_milliseconds)), |
785 close_sessions_on_ip_change_(close_sessions_on_ip_change), | 799 close_sessions_on_ip_change_(close_sessions_on_ip_change), |
786 migrate_sessions_on_network_change_( | 800 migrate_sessions_on_network_change_( |
787 migrate_sessions_on_network_change && | 801 migrate_sessions_on_network_change && |
788 NetworkChangeNotifier::AreNetworkHandlesSupported()), | 802 NetworkChangeNotifier::AreNetworkHandlesSupported()), |
789 migrate_sessions_early_(migrate_sessions_early && | 803 migrate_sessions_early_(migrate_sessions_early && |
790 migrate_sessions_on_network_change_), | 804 migrate_sessions_on_network_change_), |
791 allow_server_migration_(allow_server_migration), | 805 allow_server_migration_(allow_server_migration), |
792 force_hol_blocking_(force_hol_blocking), | 806 force_hol_blocking_(force_hol_blocking), |
793 race_cert_verification_(race_cert_verification), | 807 race_cert_verification_(race_cert_verification), |
794 quic_do_not_fragment_(quic_do_not_fragment), | 808 quic_do_not_fragment_(quic_do_not_fragment), |
795 port_seed_(random_generator_->RandUint64()), | 809 port_seed_(random_generator_->RandUint64()), |
796 check_persisted_supports_quic_(true), | 810 check_persisted_supports_quic_(true), |
797 has_initialized_data_(false), | 811 has_initialized_data_(false), |
798 num_push_streams_created_(0), | 812 num_push_streams_created_(0), |
799 status_(OPEN), | 813 status_(OPEN), |
800 task_runner_(nullptr), | 814 task_runner_(nullptr), |
801 ssl_config_service_(ssl_config_service), | 815 ssl_config_service_(ssl_config_service), |
802 weak_factory_(this) { | 816 weak_factory_(this) { |
803 if (ssl_config_service_.get()) | 817 if (ssl_config_service_.get()) |
804 ssl_config_service_->AddObserver(this); | 818 ssl_config_service_->AddObserver(this); |
| 819 if (disable_quic_on_timeout_with_open_streams) |
| 820 threshold_timeouts_with_open_streams_ = 1; |
805 DCHECK(transport_security_state_); | 821 DCHECK(transport_security_state_); |
806 DCHECK(http_server_properties_); | 822 DCHECK(http_server_properties_); |
807 crypto_config_.set_user_agent_id(user_agent_id); | 823 crypto_config_.set_user_agent_id(user_agent_id); |
808 crypto_config_.AddCanonicalSuffix(".c.youtube.com"); | 824 crypto_config_.AddCanonicalSuffix(".c.youtube.com"); |
809 crypto_config_.AddCanonicalSuffix(".ggpht.com"); | 825 crypto_config_.AddCanonicalSuffix(".ggpht.com"); |
810 crypto_config_.AddCanonicalSuffix(".googlevideo.com"); | 826 crypto_config_.AddCanonicalSuffix(".googlevideo.com"); |
811 crypto_config_.AddCanonicalSuffix(".googleusercontent.com"); | 827 crypto_config_.AddCanonicalSuffix(".googleusercontent.com"); |
812 // TODO(rtenneti): http://crbug.com/487355. Temporary fix for b/20760730 until | 828 // TODO(rtenneti): http://crbug.com/487355. Temporary fix for b/20760730 until |
813 // channel_id_service is supported in cronet. | 829 // channel_id_service is supported in cronet. |
814 if (channel_id_service) { | 830 if (channel_id_service) { |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1130 void QuicStreamFactory::OnCertVerifyJobComplete(CertVerifierJob* job, int rv) { | 1146 void QuicStreamFactory::OnCertVerifyJobComplete(CertVerifierJob* job, int rv) { |
1131 active_cert_verifier_jobs_.erase(job->server_id()); | 1147 active_cert_verifier_jobs_.erase(job->server_id()); |
1132 } | 1148 } |
1133 | 1149 |
1134 std::unique_ptr<QuicHttpStream> QuicStreamFactory::CreateFromSession( | 1150 std::unique_ptr<QuicHttpStream> QuicStreamFactory::CreateFromSession( |
1135 QuicChromiumClientSession* session) { | 1151 QuicChromiumClientSession* session) { |
1136 return std::unique_ptr<QuicHttpStream>( | 1152 return std::unique_ptr<QuicHttpStream>( |
1137 new QuicHttpStream(session->GetWeakPtr())); | 1153 new QuicHttpStream(session->GetWeakPtr())); |
1138 } | 1154 } |
1139 | 1155 |
1140 bool QuicStreamFactory::IsQuicDisabled() const { | 1156 QuicChromiumClientSession::QuicDisabledReason |
| 1157 QuicStreamFactory::QuicDisabledReason(uint16_t port) const { |
| 1158 if (max_number_of_lossy_connections_ > 0 && |
| 1159 number_of_lossy_connections_.find(port) != |
| 1160 number_of_lossy_connections_.end() && |
| 1161 number_of_lossy_connections_.at(port) >= |
| 1162 max_number_of_lossy_connections_) { |
| 1163 return QuicChromiumClientSession::QUIC_DISABLED_BAD_PACKET_LOSS_RATE; |
| 1164 } |
| 1165 if (threshold_public_resets_post_handshake_ > 0 && |
| 1166 num_public_resets_post_handshake_ >= |
| 1167 threshold_public_resets_post_handshake_) { |
| 1168 return QuicChromiumClientSession::QUIC_DISABLED_PUBLIC_RESET_POST_HANDSHAKE; |
| 1169 } |
| 1170 if (threshold_timeouts_with_open_streams_ > 0 && |
| 1171 num_timeouts_with_open_streams_ >= |
| 1172 threshold_timeouts_with_open_streams_) { |
| 1173 return QuicChromiumClientSession::QUIC_DISABLED_TIMEOUT_WITH_OPEN_STREAMS; |
| 1174 } |
| 1175 return QuicChromiumClientSession::QUIC_DISABLED_NOT; |
| 1176 } |
| 1177 |
| 1178 const char* QuicStreamFactory::QuicDisabledReasonString() const { |
| 1179 // TODO(ckrasic) - better solution for port/lossy connections? |
| 1180 const uint16_t port = 443; |
| 1181 switch (QuicDisabledReason(port)) { |
| 1182 case QuicChromiumClientSession::QUIC_DISABLED_BAD_PACKET_LOSS_RATE: |
| 1183 return "Bad packet loss rate."; |
| 1184 case QuicChromiumClientSession::QUIC_DISABLED_PUBLIC_RESET_POST_HANDSHAKE: |
| 1185 return "Public resets after successful handshakes."; |
| 1186 case QuicChromiumClientSession::QUIC_DISABLED_TIMEOUT_WITH_OPEN_STREAMS: |
| 1187 return "Connection timeouts with streams open."; |
| 1188 default: |
| 1189 return ""; |
| 1190 } |
| 1191 } |
| 1192 |
| 1193 bool QuicStreamFactory::IsQuicDisabled(uint16_t port) const { |
1141 return status_ != OPEN; | 1194 return status_ != OPEN; |
1142 } | 1195 } |
1143 | 1196 |
1144 bool QuicStreamFactory::OnHandshakeConfirmed( | 1197 bool QuicStreamFactory::OnHandshakeConfirmed(QuicChromiumClientSession* session, |
1145 QuicChromiumClientSession* session) { | 1198 float packet_loss_rate) { |
1146 if (!IsQuicDisabled()) | 1199 DCHECK(session); |
| 1200 uint16_t port = session->server_id().port(); |
| 1201 if (packet_loss_rate < packet_loss_threshold_) { |
| 1202 number_of_lossy_connections_[port] = 0; |
1147 return false; | 1203 return false; |
| 1204 } |
1148 | 1205 |
1149 session->CloseSessionOnErrorAndNotifyFactoryLater( | 1206 // We mark it as recently broken, which means that 0-RTT will be disabled |
1150 ERR_ABORTED, QUIC_TIMEOUTS_WITH_OPEN_STREAMS); | 1207 // but we'll still race. |
| 1208 http_server_properties_->MarkAlternativeServiceRecentlyBroken( |
| 1209 AlternativeService(QUIC, session->server_id().host(), port)); |
1151 | 1210 |
1152 return true; | 1211 bool was_quic_disabled = IsQuicDisabled(port); |
| 1212 ++number_of_lossy_connections_[port]; |
| 1213 |
| 1214 // Collect data for port 443 for packet loss events. |
| 1215 if (port == 443 && max_number_of_lossy_connections_ > 0) { |
| 1216 UMA_HISTOGRAM_SPARSE_SLOWLY( |
| 1217 base::StringPrintf("Net.QuicStreamFactory.BadPacketLossEvents%d", |
| 1218 max_number_of_lossy_connections_), |
| 1219 std::min(number_of_lossy_connections_[port], |
| 1220 max_number_of_lossy_connections_)); |
| 1221 } |
| 1222 |
| 1223 MaybeDisableQuic(port); |
| 1224 |
| 1225 bool is_quic_disabled = IsQuicDisabled(port); |
| 1226 if (is_quic_disabled) { |
| 1227 // Close QUIC connection if Quic is disabled for this port. |
| 1228 session->CloseSessionOnErrorAndNotifyFactoryLater( |
| 1229 ERR_ABORTED, QUIC_BAD_PACKET_LOSS_RATE); |
| 1230 |
| 1231 // If this bad packet loss rate disabled the QUIC, then record it. |
| 1232 if (!was_quic_disabled) |
| 1233 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.QuicStreamFactory.QuicIsDisabled", port); |
| 1234 } |
| 1235 return is_quic_disabled; |
1153 } | 1236 } |
1154 | 1237 |
1155 void QuicStreamFactory::OnTcpJobCompleted(bool succeeded) { | 1238 void QuicStreamFactory::OnTcpJobCompleted(bool succeeded) { |
1156 if (status_ != CLOSED) | 1239 if (status_ != CLOSED) |
1157 return; | 1240 return; |
1158 | 1241 |
1159 // If QUIC connections are failing while TCP connections are working, | 1242 // If QUIC connections are failing while TCP connections are working, |
1160 // then stop using QUIC. On the other hand if both QUIC and TCP are | 1243 // then stop using QUIC. On the other hand if both QUIC and TCP are |
1161 // failing, then attempt to use QUIC again. | 1244 // failing, then attempt to use QUIC again. |
1162 if (succeeded) { | 1245 if (succeeded) { |
1163 status_ = DISABLED; | 1246 status_ = DISABLED; |
1164 return; | 1247 return; |
1165 } | 1248 } |
1166 | 1249 |
1167 status_ = OPEN; | 1250 status_ = OPEN; |
| 1251 num_timeouts_with_open_streams_ = 0; |
1168 } | 1252 } |
1169 | 1253 |
1170 void QuicStreamFactory::OnIdleSession(QuicChromiumClientSession* session) {} | 1254 void QuicStreamFactory::OnIdleSession(QuicChromiumClientSession* session) {} |
1171 | 1255 |
1172 void QuicStreamFactory::OnSessionGoingAway(QuicChromiumClientSession* session) { | 1256 void QuicStreamFactory::OnSessionGoingAway(QuicChromiumClientSession* session) { |
1173 const AliasSet& aliases = session_aliases_[session]; | 1257 const AliasSet& aliases = session_aliases_[session]; |
1174 for (AliasSet::const_iterator it = aliases.begin(); it != aliases.end(); | 1258 for (AliasSet::const_iterator it = aliases.begin(); it != aliases.end(); |
1175 ++it) { | 1259 ++it) { |
1176 const QuicServerId& server_id = it->server_id(); | 1260 const QuicServerId& server_id = it->server_id(); |
1177 DCHECK(active_sessions_.count(server_id)); | 1261 DCHECK(active_sessions_.count(server_id)); |
(...skipping 11 matching lines...) Expand all Loading... |
1189 DCHECK(base::ContainsKey(session_peer_ip_, session)); | 1273 DCHECK(base::ContainsKey(session_peer_ip_, session)); |
1190 const IPEndPoint peer_address = session_peer_ip_[session]; | 1274 const IPEndPoint peer_address = session_peer_ip_[session]; |
1191 ip_aliases_[peer_address].erase(session); | 1275 ip_aliases_[peer_address].erase(session); |
1192 if (ip_aliases_[peer_address].empty()) | 1276 if (ip_aliases_[peer_address].empty()) |
1193 ip_aliases_.erase(peer_address); | 1277 ip_aliases_.erase(peer_address); |
1194 session_peer_ip_.erase(session); | 1278 session_peer_ip_.erase(session); |
1195 } | 1279 } |
1196 session_aliases_.erase(session); | 1280 session_aliases_.erase(session); |
1197 } | 1281 } |
1198 | 1282 |
| 1283 void QuicStreamFactory::MaybeDisableQuic(QuicChromiumClientSession* session) { |
| 1284 DCHECK(session); |
| 1285 uint16_t port = session->server_id().port(); |
| 1286 if (IsQuicDisabled(port)) |
| 1287 return; |
| 1288 |
| 1289 // Expire the oldest disabled_reason if appropriate. This enforces that we |
| 1290 // only consider the max_disabled_reasons_ most recent sessions. |
| 1291 QuicChromiumClientSession::QuicDisabledReason disabled_reason; |
| 1292 if (static_cast<int>(disabled_reasons_.size()) == max_disabled_reasons_) { |
| 1293 disabled_reason = disabled_reasons_.front(); |
| 1294 disabled_reasons_.pop_front(); |
| 1295 if (disabled_reason == |
| 1296 QuicChromiumClientSession::QUIC_DISABLED_PUBLIC_RESET_POST_HANDSHAKE) { |
| 1297 --num_public_resets_post_handshake_; |
| 1298 } else if (disabled_reason == QuicChromiumClientSession:: |
| 1299 QUIC_DISABLED_TIMEOUT_WITH_OPEN_STREAMS) { |
| 1300 --num_timeouts_with_open_streams_; |
| 1301 } |
| 1302 } |
| 1303 disabled_reason = session->disabled_reason(); |
| 1304 disabled_reasons_.push_back(disabled_reason); |
| 1305 if (disabled_reason == |
| 1306 QuicChromiumClientSession::QUIC_DISABLED_PUBLIC_RESET_POST_HANDSHAKE) { |
| 1307 ++num_public_resets_post_handshake_; |
| 1308 } else if (disabled_reason == QuicChromiumClientSession:: |
| 1309 QUIC_DISABLED_TIMEOUT_WITH_OPEN_STREAMS) { |
| 1310 ++num_timeouts_with_open_streams_; |
| 1311 } |
| 1312 if (num_timeouts_with_open_streams_ > max_timeouts_with_open_streams_) { |
| 1313 max_timeouts_with_open_streams_ = num_timeouts_with_open_streams_; |
| 1314 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.QuicStreamFactory.TimeoutsWithOpenStreams", |
| 1315 num_timeouts_with_open_streams_, 1, 20, 10); |
| 1316 } |
| 1317 |
| 1318 if (num_public_resets_post_handshake_ > max_public_resets_post_handshake_) { |
| 1319 max_public_resets_post_handshake_ = num_public_resets_post_handshake_; |
| 1320 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 1321 "Net.QuicStreamFactory.PublicResetsPostHandshake", |
| 1322 num_public_resets_post_handshake_, 1, 20, 10); |
| 1323 } |
| 1324 |
| 1325 MaybeDisableQuic(port); |
| 1326 if (IsQuicDisabled(port)) { |
| 1327 if (disabled_reason == |
| 1328 QuicChromiumClientSession::QUIC_DISABLED_PUBLIC_RESET_POST_HANDSHAKE) { |
| 1329 session->CloseSessionOnErrorAndNotifyFactoryLater( |
| 1330 ERR_ABORTED, QUIC_PUBLIC_RESETS_POST_HANDSHAKE); |
| 1331 } else if (disabled_reason == QuicChromiumClientSession:: |
| 1332 QUIC_DISABLED_TIMEOUT_WITH_OPEN_STREAMS) { |
| 1333 session->CloseSessionOnErrorAndNotifyFactoryLater( |
| 1334 ERR_ABORTED, QUIC_TIMEOUTS_WITH_OPEN_STREAMS); |
| 1335 } |
| 1336 UMA_HISTOGRAM_ENUMERATION("Net.QuicStreamFactory.DisabledReasons", |
| 1337 disabled_reason, |
| 1338 QuicChromiumClientSession::QUIC_DISABLED_MAX); |
| 1339 } |
| 1340 } |
| 1341 |
| 1342 void QuicStreamFactory::MaybeDisableQuic(uint16_t port) { |
| 1343 if (status_ == DISABLED) |
| 1344 return; |
| 1345 |
| 1346 QuicChromiumClientSession::QuicDisabledReason disabled_reason = |
| 1347 QuicDisabledReason(port); |
| 1348 if (disabled_reason == QuicChromiumClientSession::QUIC_DISABLED_NOT) { |
| 1349 DCHECK_EQ(OPEN, status_); |
| 1350 return; |
| 1351 } |
| 1352 |
| 1353 if (disabled_reason == |
| 1354 QuicChromiumClientSession::QUIC_DISABLED_TIMEOUT_WITH_OPEN_STREAMS) { |
| 1355 // When QUIC there are too many timeouts with open stream, the factory |
| 1356 // should be closed. When TCP jobs complete, they will move the factory |
| 1357 // to either fully disabled or back to open. |
| 1358 status_ = CLOSED; |
| 1359 DCHECK(IsQuicDisabled(port)); |
| 1360 DCHECK_NE(QuicChromiumClientSession::QuicDisabledReason(port), |
| 1361 QuicChromiumClientSession::QUIC_DISABLED_NOT); |
| 1362 return; |
| 1363 } |
| 1364 |
| 1365 status_ = DISABLED; |
| 1366 DCHECK(IsQuicDisabled(port)); |
| 1367 DCHECK_NE(QuicChromiumClientSession::QuicDisabledReason(port), |
| 1368 QuicChromiumClientSession::QUIC_DISABLED_NOT); |
| 1369 } |
| 1370 |
1199 void QuicStreamFactory::OnSessionClosed(QuicChromiumClientSession* session) { | 1371 void QuicStreamFactory::OnSessionClosed(QuicChromiumClientSession* session) { |
1200 DCHECK_EQ(0u, session->GetNumActiveStreams()); | 1372 DCHECK_EQ(0u, session->GetNumActiveStreams()); |
| 1373 MaybeDisableQuic(session); |
1201 OnSessionGoingAway(session); | 1374 OnSessionGoingAway(session); |
1202 delete session; | 1375 delete session; |
1203 all_sessions_.erase(session); | 1376 all_sessions_.erase(session); |
1204 } | 1377 } |
1205 | 1378 |
1206 void QuicStreamFactory::OnTimeoutWithOpenStreams() { | 1379 void QuicStreamFactory::OnTimeoutWithOpenStreams() { |
1207 // Reduce PING timeout when connection times out with open stream. | 1380 // Reduce PING timeout when connection times out with open stream. |
1208 if (ping_timeout_ > reduced_ping_timeout_) { | 1381 if (ping_timeout_ > reduced_ping_timeout_) { |
1209 ping_timeout_ = reduced_ping_timeout_; | 1382 ping_timeout_ = reduced_ping_timeout_; |
1210 } | 1383 } |
1211 if (disable_quic_on_timeout_with_open_streams_) | |
1212 status_ = CLOSED; | |
1213 } | 1384 } |
1214 | 1385 |
1215 void QuicStreamFactory::CancelRequest(QuicStreamRequest* request) { | 1386 void QuicStreamFactory::CancelRequest(QuicStreamRequest* request) { |
1216 RequestMap::iterator request_it = active_requests_.find(request); | 1387 RequestMap::iterator request_it = active_requests_.find(request); |
1217 DCHECK(request_it != active_requests_.end()); | 1388 DCHECK(request_it != active_requests_.end()); |
1218 const QuicServerId& server_id = request_it->second; | 1389 const QuicServerId& server_id = request_it->second; |
1219 job_requests_map_[server_id].erase(request); | 1390 job_requests_map_[server_id].erase(request); |
1220 active_requests_.erase(request_it); | 1391 active_requests_.erase(request_it); |
1221 } | 1392 } |
1222 | 1393 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1257 return std::move(list); | 1428 return std::move(list); |
1258 } | 1429 } |
1259 | 1430 |
1260 void QuicStreamFactory::ClearCachedStatesInCryptoConfig( | 1431 void QuicStreamFactory::ClearCachedStatesInCryptoConfig( |
1261 const base::Callback<bool(const GURL&)>& origin_filter) { | 1432 const base::Callback<bool(const GURL&)>& origin_filter) { |
1262 ServerIdOriginFilter filter(origin_filter); | 1433 ServerIdOriginFilter filter(origin_filter); |
1263 crypto_config_.ClearCachedStates(filter); | 1434 crypto_config_.ClearCachedStates(filter); |
1264 } | 1435 } |
1265 | 1436 |
1266 void QuicStreamFactory::OnIPAddressChanged() { | 1437 void QuicStreamFactory::OnIPAddressChanged() { |
| 1438 num_timeouts_with_open_streams_ = 0; |
1267 status_ = OPEN; | 1439 status_ = OPEN; |
1268 CloseAllSessions(ERR_NETWORK_CHANGED, QUIC_IP_ADDRESS_CHANGED); | 1440 CloseAllSessions(ERR_NETWORK_CHANGED, QUIC_IP_ADDRESS_CHANGED); |
1269 set_require_confirmation(true); | 1441 set_require_confirmation(true); |
1270 } | 1442 } |
1271 | 1443 |
1272 void QuicStreamFactory::OnNetworkConnected(NetworkHandle network) { | 1444 void QuicStreamFactory::OnNetworkConnected(NetworkHandle network) { |
| 1445 num_timeouts_with_open_streams_ = 0; |
1273 status_ = OPEN; | 1446 status_ = OPEN; |
1274 } | 1447 } |
1275 | 1448 |
1276 void QuicStreamFactory::OnNetworkMadeDefault(NetworkHandle network) { | 1449 void QuicStreamFactory::OnNetworkMadeDefault(NetworkHandle network) { |
1277 ScopedConnectionMigrationEventLog scoped_event_log(net_log_, | 1450 ScopedConnectionMigrationEventLog scoped_event_log(net_log_, |
1278 "OnNetworkMadeDefault"); | 1451 "OnNetworkMadeDefault"); |
1279 DCHECK_NE(NetworkChangeNotifier::kInvalidNetworkHandle, network); | 1452 DCHECK_NE(NetworkChangeNotifier::kInvalidNetworkHandle, network); |
1280 MaybeMigrateOrCloseSessions(network, /*close_if_cannot_migrate=*/false, | 1453 MaybeMigrateOrCloseSessions(network, /*close_if_cannot_migrate=*/false, |
1281 scoped_event_log.net_log()); | 1454 scoped_event_log.net_log()); |
1282 set_require_confirmation(true); | 1455 set_require_confirmation(true); |
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1879 // Since the session was active, there's no longer an | 2052 // Since the session was active, there's no longer an |
1880 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP | 2053 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP |
1881 // job also fails. So to avoid not using QUIC when we otherwise could, we mark | 2054 // job also fails. So to avoid not using QUIC when we otherwise could, we mark |
1882 // it as recently broken, which means that 0-RTT will be disabled but we'll | 2055 // it as recently broken, which means that 0-RTT will be disabled but we'll |
1883 // still race. | 2056 // still race. |
1884 http_server_properties_->MarkAlternativeServiceRecentlyBroken( | 2057 http_server_properties_->MarkAlternativeServiceRecentlyBroken( |
1885 alternative_service); | 2058 alternative_service); |
1886 } | 2059 } |
1887 | 2060 |
1888 } // namespace net | 2061 } // namespace net |
OLD | NEW |