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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
83 MIGRATION_STATUS_MAX | 83 MIGRATION_STATUS_MAX |
84 }; | 84 }; |
85 | 85 |
86 // The maximum receive window sizes for QUIC sessions and streams. | 86 // The maximum receive window sizes for QUIC sessions and streams. |
87 const int32_t kQuicSessionMaxRecvWindowSize = 15 * 1024 * 1024; // 15 MB | 87 const int32_t kQuicSessionMaxRecvWindowSize = 15 * 1024 * 1024; // 15 MB |
88 const int32_t kQuicStreamMaxRecvWindowSize = 6 * 1024 * 1024; // 6 MB | 88 const int32_t kQuicStreamMaxRecvWindowSize = 6 * 1024 * 1024; // 6 MB |
89 | 89 |
90 // Set the maximum number of undecryptable packets the connection will store. | 90 // Set the maximum number of undecryptable packets the connection will store. |
91 const int32_t kMaxUndecryptablePackets = 100; | 91 const int32_t kMaxUndecryptablePackets = 100; |
92 | 92 |
93 // How long QUIC will be disabled for because of timeouts with open streams. | |
94 const int kDisableQuicTimeoutSecs = 5 * 60; | |
95 | |
93 std::unique_ptr<base::Value> NetLogQuicConnectionMigrationTriggerCallback( | 96 std::unique_ptr<base::Value> NetLogQuicConnectionMigrationTriggerCallback( |
94 std::string trigger, | 97 std::string trigger, |
95 NetLogCaptureMode capture_mode) { | 98 NetLogCaptureMode capture_mode) { |
96 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 99 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
97 dict->SetString("trigger", trigger); | 100 dict->SetString("trigger", trigger); |
98 return std::move(dict); | 101 return std::move(dict); |
99 } | 102 } |
100 | 103 |
101 std::unique_ptr<base::Value> NetLogQuicConnectionMigrationFailureCallback( | 104 std::unique_ptr<base::Value> NetLogQuicConnectionMigrationFailureCallback( |
102 QuicConnectionId connection_id, | 105 QuicConnectionId connection_id, |
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
767 always_require_handshake_confirmation), | 770 always_require_handshake_confirmation), |
768 disable_connection_pooling_(disable_connection_pooling), | 771 disable_connection_pooling_(disable_connection_pooling), |
769 load_server_info_timeout_srtt_multiplier_( | 772 load_server_info_timeout_srtt_multiplier_( |
770 load_server_info_timeout_srtt_multiplier), | 773 load_server_info_timeout_srtt_multiplier), |
771 enable_connection_racing_(enable_connection_racing), | 774 enable_connection_racing_(enable_connection_racing), |
772 enable_non_blocking_io_(enable_non_blocking_io), | 775 enable_non_blocking_io_(enable_non_blocking_io), |
773 disable_disk_cache_(disable_disk_cache), | 776 disable_disk_cache_(disable_disk_cache), |
774 prefer_aes_(prefer_aes), | 777 prefer_aes_(prefer_aes), |
775 disable_quic_on_timeout_with_open_streams_( | 778 disable_quic_on_timeout_with_open_streams_( |
776 disable_quic_on_timeout_with_open_streams), | 779 disable_quic_on_timeout_with_open_streams), |
780 consecutive_disabled_count_(0), | |
781 need_to_evaluate_consecutive_disabled_count_(false), | |
777 socket_receive_buffer_size_(socket_receive_buffer_size), | 782 socket_receive_buffer_size_(socket_receive_buffer_size), |
778 delay_tcp_race_(delay_tcp_race), | 783 delay_tcp_race_(delay_tcp_race), |
779 ping_timeout_(QuicTime::Delta::FromSeconds(kPingTimeoutSecs)), | 784 ping_timeout_(QuicTime::Delta::FromSeconds(kPingTimeoutSecs)), |
780 reduced_ping_timeout_( | 785 reduced_ping_timeout_( |
781 QuicTime::Delta::FromSeconds(reduced_ping_timeout_seconds)), | 786 QuicTime::Delta::FromSeconds(reduced_ping_timeout_seconds)), |
782 yield_after_packets_(kQuicYieldAfterPacketsRead), | 787 yield_after_packets_(kQuicYieldAfterPacketsRead), |
783 yield_after_duration_(QuicTime::Delta::FromMilliseconds( | 788 yield_after_duration_(QuicTime::Delta::FromMilliseconds( |
784 packet_reader_yield_after_duration_milliseconds)), | 789 packet_reader_yield_after_duration_milliseconds)), |
785 close_sessions_on_ip_change_(close_sessions_on_ip_change), | 790 close_sessions_on_ip_change_(close_sessions_on_ip_change), |
786 migrate_sessions_on_network_change_( | 791 migrate_sessions_on_network_change_( |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1201 OnSessionGoingAway(session); | 1206 OnSessionGoingAway(session); |
1202 delete session; | 1207 delete session; |
1203 all_sessions_.erase(session); | 1208 all_sessions_.erase(session); |
1204 } | 1209 } |
1205 | 1210 |
1206 void QuicStreamFactory::OnTimeoutWithOpenStreams() { | 1211 void QuicStreamFactory::OnTimeoutWithOpenStreams() { |
1207 // Reduce PING timeout when connection times out with open stream. | 1212 // Reduce PING timeout when connection times out with open stream. |
1208 if (ping_timeout_ > reduced_ping_timeout_) { | 1213 if (ping_timeout_ > reduced_ping_timeout_) { |
1209 ping_timeout_ = reduced_ping_timeout_; | 1214 ping_timeout_ = reduced_ping_timeout_; |
1210 } | 1215 } |
1211 if (disable_quic_on_timeout_with_open_streams_) | 1216 if (disable_quic_on_timeout_with_open_streams_) { |
1217 if (status_ == OPEN) { | |
1218 task_runner_->PostDelayedTask( | |
ianswett
2016/09/14 20:10:14
Can you add a one line comment on what this does?
| |
1219 FROM_HERE, base::Bind(&QuicStreamFactory::OpenFactory, | |
1220 weak_factory_.GetWeakPtr()), | |
1221 base::TimeDelta::FromSeconds(kDisableQuicTimeoutSecs * | |
1222 (1 << consecutive_disabled_count_))); | |
1223 consecutive_disabled_count_++; | |
1224 need_to_evaluate_consecutive_disabled_count_ = true; | |
1225 } | |
1212 status_ = CLOSED; | 1226 status_ = CLOSED; |
1227 } | |
1213 } | 1228 } |
1214 | 1229 |
1215 void QuicStreamFactory::CancelRequest(QuicStreamRequest* request) { | 1230 void QuicStreamFactory::CancelRequest(QuicStreamRequest* request) { |
1216 RequestMap::iterator request_it = active_requests_.find(request); | 1231 RequestMap::iterator request_it = active_requests_.find(request); |
1217 DCHECK(request_it != active_requests_.end()); | 1232 DCHECK(request_it != active_requests_.end()); |
1218 const QuicServerId& server_id = request_it->second; | 1233 const QuicServerId& server_id = request_it->second; |
1219 job_requests_map_[server_id].erase(request); | 1234 job_requests_map_[server_id].erase(request); |
1220 active_requests_.erase(request_it); | 1235 active_requests_.erase(request_it); |
1221 } | 1236 } |
1222 | 1237 |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1586 } | 1601 } |
1587 | 1602 |
1588 int QuicStreamFactory::CreateSession( | 1603 int QuicStreamFactory::CreateSession( |
1589 const QuicSessionKey& key, | 1604 const QuicSessionKey& key, |
1590 int cert_verify_flags, | 1605 int cert_verify_flags, |
1591 std::unique_ptr<QuicServerInfo> server_info, | 1606 std::unique_ptr<QuicServerInfo> server_info, |
1592 const AddressList& address_list, | 1607 const AddressList& address_list, |
1593 base::TimeTicks dns_resolution_end_time, | 1608 base::TimeTicks dns_resolution_end_time, |
1594 const BoundNetLog& net_log, | 1609 const BoundNetLog& net_log, |
1595 QuicChromiumClientSession** session) { | 1610 QuicChromiumClientSession** session) { |
1611 if (need_to_evaluate_consecutive_disabled_count_) { | |
1612 task_runner_->PostDelayedTask( | |
ianswett
2016/09/14 20:10:14
Small comment please.
| |
1613 FROM_HERE, | |
1614 base::Bind(&QuicStreamFactory::MaybeClearConsecutiveDisabledCount, | |
1615 weak_factory_.GetWeakPtr()), | |
1616 base::TimeDelta::FromSeconds(kDisableQuicTimeoutSecs)); | |
1617 | |
1618 need_to_evaluate_consecutive_disabled_count_ = false; | |
1619 } | |
1596 TRACE_EVENT0("net", "QuicStreamFactory::CreateSession"); | 1620 TRACE_EVENT0("net", "QuicStreamFactory::CreateSession"); |
1597 IPEndPoint addr = *address_list.begin(); | 1621 IPEndPoint addr = *address_list.begin(); |
1598 bool enable_port_selection = enable_port_selection_; | 1622 bool enable_port_selection = enable_port_selection_; |
1599 if (enable_port_selection && base::ContainsKey(gone_away_aliases_, key)) { | 1623 if (enable_port_selection && base::ContainsKey(gone_away_aliases_, key)) { |
1600 // Disable port selection when the server is going away. | 1624 // Disable port selection when the server is going away. |
1601 // There is no point in trying to return to the same server, if | 1625 // There is no point in trying to return to the same server, if |
1602 // that server is no longer handling requests. | 1626 // that server is no longer handling requests. |
1603 enable_port_selection = false; | 1627 enable_port_selection = false; |
1604 gone_away_aliases_.erase(key); | 1628 gone_away_aliases_.erase(key); |
1605 } | 1629 } |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1878 | 1902 |
1879 // Since the session was active, there's no longer an | 1903 // Since the session was active, there's no longer an |
1880 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP | 1904 // 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 | 1905 // 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 | 1906 // it as recently broken, which means that 0-RTT will be disabled but we'll |
1883 // still race. | 1907 // still race. |
1884 http_server_properties_->MarkAlternativeServiceRecentlyBroken( | 1908 http_server_properties_->MarkAlternativeServiceRecentlyBroken( |
1885 alternative_service); | 1909 alternative_service); |
1886 } | 1910 } |
1887 | 1911 |
1912 void QuicStreamFactory::OpenFactory() { | |
1913 status_ = OPEN; | |
1914 } | |
1915 | |
1916 void QuicStreamFactory::MaybeClearConsecutiveDisabledCount() { | |
1917 if (status_ == OPEN) | |
1918 consecutive_disabled_count_ = 0; | |
1919 } | |
1920 | |
1888 } // namespace net | 1921 } // namespace net |
OLD | NEW |