diff options
author | Bacek@yandex-team.ru <Bacek@yandex-team.ru@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-20 17:52:05 +0000 |
---|---|---|
committer | Bacek@yandex-team.ru <Bacek@yandex-team.ru@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-20 17:52:05 +0000 |
commit | fc6dc0d8f4382ef02b5259a718e3f130630b4e01 (patch) | |
tree | 13600acddab4460b9377e3915a0b7571df8c4f51 /net/tools/flip_server | |
parent | 823bd5cae64daaf9548fb3d62904136bb3016ff2 (diff) | |
download | chromium_src-fc6dc0d8f4382ef02b5259a718e3f130630b4e01.zip chromium_src-fc6dc0d8f4382ef02b5259a718e3f130630b4e01.tar.gz chromium_src-fc6dc0d8f4382ef02b5259a718e3f130630b4e01.tar.bz2 |
Set new negotiated SPDY version after reusing of SpdySM
R=yhirano@chromium.org
Review URL: https://codereview.chromium.org/169283002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@252304 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/tools/flip_server')
-rw-r--r-- | net/tools/flip_server/sm_connection.cc | 4 | ||||
-rw-r--r-- | net/tools/flip_server/sm_connection.h | 3 | ||||
-rw-r--r-- | net/tools/flip_server/spdy_interface.cc | 18 | ||||
-rw-r--r-- | net/tools/flip_server/spdy_interface.h | 3 | ||||
-rw-r--r-- | net/tools/flip_server/spdy_interface_test.cc | 14 |
5 files changed, 37 insertions, 5 deletions
diff --git a/net/tools/flip_server/sm_connection.cc b/net/tools/flip_server/sm_connection.cc index 158cd30f..4acdea4 100644 --- a/net/tools/flip_server/sm_connection.cc +++ b/net/tools/flip_server/sm_connection.cc @@ -391,7 +391,9 @@ bool SMConnection::SetupProtocolInterfaces() { VLOG(2) << log_prefix_ << ACCEPTOR_CLIENT_IDENT << (sm_spdy_interface_ ? "Creating" : "Reusing") << " SPDY interface."; - if (!sm_spdy_interface_) + if (sm_spdy_interface_) + sm_spdy_interface_->CreateFramer(version); + else sm_spdy_interface_ = new SpdySM( this, NULL, epoll_server_, memory_cache_, acceptor_, version); sm_interface_ = sm_spdy_interface_; diff --git a/net/tools/flip_server/sm_connection.h b/net/tools/flip_server/sm_connection.h index 93ad42e..2fe3228 100644 --- a/net/tools/flip_server/sm_connection.h +++ b/net/tools/flip_server/sm_connection.h @@ -25,6 +25,7 @@ namespace net { class FlipAcceptor; class MemoryCache; struct SSLState; +class SpdySM; // A frame of data to be sent. class DataFrame { @@ -146,7 +147,7 @@ class SMConnection : public SMConnectionInterface, RingBuffer read_buffer_; OutputList output_list_; - SMInterface* sm_spdy_interface_; + SpdySM* sm_spdy_interface_; SMInterface* sm_http_interface_; SMInterface* sm_streamer_interface_; SMInterface* sm_interface_; diff --git a/net/tools/flip_server/spdy_interface.cc b/net/tools/flip_server/spdy_interface.cc index e462ca6..e53b017 100644 --- a/net/tools/flip_server/spdy_interface.cc +++ b/net/tools/flip_server/spdy_interface.cc @@ -297,21 +297,25 @@ void SpdySM::OnRstStream(SpdyStreamId stream_id, SpdyRstStreamStatus status) { } size_t SpdySM::ProcessReadInput(const char* data, size_t len) { + DCHECK(buffered_spdy_framer_); return buffered_spdy_framer_->ProcessInput(data, len); } size_t SpdySM::ProcessWriteInput(const char* data, size_t len) { return 0; } bool SpdySM::MessageFullyRead() const { + DCHECK(buffered_spdy_framer_); return buffered_spdy_framer_->MessageFullyRead(); } bool SpdySM::Error() const { + DCHECK(buffered_spdy_framer_); return close_on_error_ || buffered_spdy_framer_->HasError(); } const char* SpdySM::ErrorAsString() const { DCHECK(Error()); + DCHECK(buffered_spdy_framer_); return SpdyFramer::ErrorCodeToString(buffered_spdy_framer_->error_code()); } @@ -324,8 +328,7 @@ void SpdySM::ResetForNewInterface(int32 server_idx) { void SpdySM::ResetForNewConnection() { // seq_num is not cleared, intentionally. delete buffered_spdy_framer_; - buffered_spdy_framer_ = new BufferedSpdyFramer(SPDY2, true); - buffered_spdy_framer_->set_visitor(this); + buffered_spdy_framer_ = NULL; valid_spdy_session_ = false; client_output_ordering_.Reset(); next_outgoing_stream_id_ = 2; @@ -333,6 +336,8 @@ void SpdySM::ResetForNewConnection() { // Send a settings frame int SpdySM::PostAcceptHook() { + // We should have buffered_spdy_framer_ set after reuse + DCHECK(buffered_spdy_framer_); SettingsMap settings; settings[SETTINGS_MAX_CONCURRENT_STREAMS] = SettingsFlagsAndValue(SETTINGS_FLAG_NONE, 100); @@ -470,6 +475,7 @@ size_t SpdySM::SendSynStreamImpl(uint32 stream_id, } } + DCHECK(buffered_spdy_framer_); SpdyFrame* fsrcf = buffered_spdy_framer_->CreateSynStream( stream_id, 0, 0, CONTROL_FLAG_NONE, &block); size_t df_size = fsrcf->size(); @@ -493,6 +499,7 @@ size_t SpdySM::SendSynReplyImpl(uint32 stream_id, const BalsaHeaders& headers) { block[":version"] = headers.response_version().as_string(); } + DCHECK(buffered_spdy_framer_); SpdyFrame* fsrcf = buffered_spdy_framer_->CreateSynReply( stream_id, CONTROL_FLAG_NONE, &block); size_t df_size = fsrcf->size(); @@ -508,6 +515,7 @@ void SpdySM::SendDataFrameImpl(uint32 stream_id, int64 len, SpdyDataFlags flags, bool compress) { + DCHECK(buffered_spdy_framer_); // TODO(mbelshe): We can't compress here - before going into the // priority queue. Compression needs to be done // with late binding. @@ -608,4 +616,10 @@ void SpdySM::GetOutput() { } } +void SpdySM::CreateFramer(SpdyMajorVersion spdy_version) { + DCHECK(!buffered_spdy_framer_); + buffered_spdy_framer_ = new BufferedSpdyFramer(spdy_version, true); + buffered_spdy_framer_->set_visitor(this); +} + } // namespace net diff --git a/net/tools/flip_server/spdy_interface.h b/net/tools/flip_server/spdy_interface.h index 19626e8..0d49509 100644 --- a/net/tools/flip_server/spdy_interface.h +++ b/net/tools/flip_server/spdy_interface.h @@ -45,6 +45,9 @@ class SpdySM : public BufferedSpdyFramerVisitorInterface, public SMInterface { std::string remote_ip, bool use_ssl) OVERRIDE; + // Create new SPDY framer after reusing SpdySM and negotiating new version + void CreateFramer(SpdyMajorVersion spdy_version); + private: virtual void set_is_request() OVERRIDE {} SMInterface* NewConnectionInterface(); diff --git a/net/tools/flip_server/spdy_interface_test.cc b/net/tools/flip_server/spdy_interface_test.cc index 98eb3bf..dd1980d 100644 --- a/net/tools/flip_server/spdy_interface_test.cc +++ b/net/tools/flip_server/spdy_interface_test.cc @@ -395,7 +395,19 @@ TEST_P(SpdySMProxyTest, ResetForNewConnection) { interface_->ResetForNewConnection(); ASSERT_FALSE(HasStream(stream_id)); - ASSERT_EQ(SpdyFramer::SPDY_RESET, interface_->spdy_framer()->state()); + ASSERT_TRUE(interface_->spdy_framer() == NULL); +} + +TEST_P(SpdySMProxyTest, CreateFramer) { + interface_->ResetForNewConnection(); + interface_->CreateFramer(SPDY2); + ASSERT_TRUE(interface_->spdy_framer() != NULL); + ASSERT_EQ(interface_->spdy_version(), SPDY2); + + interface_->ResetForNewConnection(); + interface_->CreateFramer(SPDY3); + ASSERT_TRUE(interface_->spdy_framer() != NULL); + ASSERT_EQ(interface_->spdy_version(), SPDY3); } TEST_P(SpdySMProxyTest, PostAcceptHook) { |