Index: net/quic/chromium/quic_stream_factory.cc |
diff --git a/net/quic/chromium/quic_stream_factory.cc b/net/quic/chromium/quic_stream_factory.cc |
index 8212a9c0366cecc3cf5d4a411710c79a23eee8df..b645b65c0be2d963ae446f03cda332f1260c00fb 100644 |
--- a/net/quic/chromium/quic_stream_factory.cc |
+++ b/net/quic/chromium/quic_stream_factory.cc |
@@ -90,6 +90,9 @@ const int32_t kQuicStreamMaxRecvWindowSize = 6 * 1024 * 1024; // 6 MB |
// Set the maximum number of undecryptable packets the connection will store. |
const int32_t kMaxUndecryptablePackets = 100; |
+// How long QUIC will be disabled for because of timeouts with open streams. |
+const int kDisableQuicTimeoutSecs = 5 * 60; |
+ |
std::unique_ptr<base::Value> NetLogQuicConnectionMigrationTriggerCallback( |
std::string trigger, |
NetLogCaptureMode capture_mode) { |
@@ -774,6 +777,8 @@ QuicStreamFactory::QuicStreamFactory( |
prefer_aes_(prefer_aes), |
disable_quic_on_timeout_with_open_streams_( |
disable_quic_on_timeout_with_open_streams), |
+ consecutive_disabled_count_(0), |
+ need_to_evaluate_consecutive_disabled_count_(false), |
socket_receive_buffer_size_(socket_receive_buffer_size), |
delay_tcp_race_(delay_tcp_race), |
ping_timeout_(QuicTime::Delta::FromSeconds(kPingTimeoutSecs)), |
@@ -1208,8 +1213,18 @@ void QuicStreamFactory::OnTimeoutWithOpenStreams() { |
if (ping_timeout_ > reduced_ping_timeout_) { |
ping_timeout_ = reduced_ping_timeout_; |
} |
- if (disable_quic_on_timeout_with_open_streams_) |
+ if (disable_quic_on_timeout_with_open_streams_) { |
+ if (status_ == OPEN) { |
+ task_runner_->PostDelayedTask( |
ianswett
2016/09/14 20:10:14
Can you add a one line comment on what this does?
|
+ FROM_HERE, base::Bind(&QuicStreamFactory::OpenFactory, |
+ weak_factory_.GetWeakPtr()), |
+ base::TimeDelta::FromSeconds(kDisableQuicTimeoutSecs * |
+ (1 << consecutive_disabled_count_))); |
+ consecutive_disabled_count_++; |
+ need_to_evaluate_consecutive_disabled_count_ = true; |
+ } |
status_ = CLOSED; |
+ } |
} |
void QuicStreamFactory::CancelRequest(QuicStreamRequest* request) { |
@@ -1593,6 +1608,15 @@ int QuicStreamFactory::CreateSession( |
base::TimeTicks dns_resolution_end_time, |
const BoundNetLog& net_log, |
QuicChromiumClientSession** session) { |
+ if (need_to_evaluate_consecutive_disabled_count_) { |
+ task_runner_->PostDelayedTask( |
ianswett
2016/09/14 20:10:14
Small comment please.
|
+ FROM_HERE, |
+ base::Bind(&QuicStreamFactory::MaybeClearConsecutiveDisabledCount, |
+ weak_factory_.GetWeakPtr()), |
+ base::TimeDelta::FromSeconds(kDisableQuicTimeoutSecs)); |
+ |
+ need_to_evaluate_consecutive_disabled_count_ = false; |
+ } |
TRACE_EVENT0("net", "QuicStreamFactory::CreateSession"); |
IPEndPoint addr = *address_list.begin(); |
bool enable_port_selection = enable_port_selection_; |
@@ -1885,4 +1909,13 @@ void QuicStreamFactory::ProcessGoingAwaySession( |
alternative_service); |
} |
+void QuicStreamFactory::OpenFactory() { |
+ status_ = OPEN; |
+} |
+ |
+void QuicStreamFactory::MaybeClearConsecutiveDisabledCount() { |
+ if (status_ == OPEN) |
+ consecutive_disabled_count_ = 0; |
+} |
+ |
} // namespace net |