Repository: trafficserver Updated Branches: refs/heads/master 8d01176a9 -> 07f707195
TS-3480 Large stream id cause PROTOCOL_ERROR Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/d38fc0a1 Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/d38fc0a1 Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/d38fc0a1 Branch: refs/heads/master Commit: d38fc0a1d2d7b95eb801a3bde009d59acdb98559 Parents: 8d01176 Author: Ryo Okubo <[email protected]> Authored: Tue Apr 7 14:48:20 2015 -0600 Committer: Leif Hedstrom <[email protected]> Committed: Tue Apr 7 14:50:29 2015 -0600 ---------------------------------------------------------------------- proxy/http2/Http2ConnectionState.cc | 9 ++++++++- proxy/http2/Http2ConnectionState.h | 5 ++++- 2 files changed, 12 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d38fc0a1/proxy/http2/Http2ConnectionState.cc ---------------------------------------------------------------------- diff --git a/proxy/http2/Http2ConnectionState.cc b/proxy/http2/Http2ConnectionState.cc index bad37a0..1e50b57 100644 --- a/proxy/http2/Http2ConnectionState.cc +++ b/proxy/http2/Http2ConnectionState.cc @@ -713,7 +713,7 @@ Http2ConnectionState::create_stream(Http2StreamId new_id) // Endpoints MUST NOT exceed the limit set by their peer. An endpoint // that receives a HEADERS frame that causes their advertised concurrent // stream limit to be exceeded MUST treat this as a stream error. - if (new_id >= client_settings.get(HTTP2_SETTINGS_MAX_CONCURRENT_STREAMS)) { + if (client_streams_count >= client_settings.get(HTTP2_SETTINGS_MAX_CONCURRENT_STREAMS)) { return NULL; } @@ -721,6 +721,9 @@ Http2ConnectionState::create_stream(Http2StreamId new_id) stream_list.push(new_stream); latest_streamid = new_id; + ink_assert(client_streams_count < UINT32_MAX); + ++client_streams_count; + return new_stream; } @@ -759,6 +762,7 @@ Http2ConnectionState::cleanup_streams() delete s; s = next; } + client_streams_count = 0; } void @@ -792,6 +796,9 @@ Http2ConnectionState::delete_stream(Http2Stream *stream) { stream_list.remove(stream); delete stream; + + ink_assert(client_streams_count > 0); + --client_streams_count; } void http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d38fc0a1/proxy/http2/Http2ConnectionState.h ---------------------------------------------------------------------- diff --git a/proxy/http2/Http2ConnectionState.h b/proxy/http2/Http2ConnectionState.h index 9d1ce1d..8f33542 100644 --- a/proxy/http2/Http2ConnectionState.h +++ b/proxy/http2/Http2ConnectionState.h @@ -189,7 +189,7 @@ class Http2ConnectionState : public Continuation public: Http2ConnectionState() : Continuation(NULL), ua_session(NULL), client_rwnd(Http2::initial_window_size), server_rwnd(Http2::initial_window_size), - stream_list(), latest_streamid(0), continued_id(0) + stream_list(), latest_streamid(0), client_streams_count(0), continued_id(0) { SET_HANDLER(&Http2ConnectionState::main_event_handler); } @@ -277,6 +277,9 @@ private: DLL<Http2Stream> stream_list; Http2StreamId latest_streamid; + // Counter for current acive streams which is started by client + uint32_t client_streams_count; + // The buffer used for storing incomplete fragments of a header field which consists of multiple frames. Http2StreamId continued_id; IOVec continued_buffer;
