diff --git a/proxy/ProxyClientTransaction.h b/proxy/ProxyClientTransaction.h index 0238707f261..64ff641f76c 100644 --- a/proxy/ProxyClientTransaction.h +++ b/proxy/ProxyClientTransaction.h @@ -59,6 +59,12 @@ class ProxyClientTransaction : public VConnection return parent ? parent->get_transact_count() : 0; } + virtual bool + is_first_transaction() const + { + return get_transact_count() == 1; + } + // Ask your session if this is allowed bool is_transparent_passthrough_allowed() diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc index b72e47bc66c..a271e138aaf 100644 --- a/proxy/http/HttpSM.cc +++ b/proxy/http/HttpSM.cc @@ -526,7 +526,7 @@ HttpSM::attach_client_session(ProxyClientTransaction *client_vc, IOBufferReader ua_session = client_vc; // Collect log & stats information - client_tcp_reused = (1 < ua_session->get_transact_count()); + client_tcp_reused = !(ua_session->is_first_transaction()); SSLNetVConnection *ssl_vc = dynamic_cast(netvc); if (ssl_vc != NULL) { client_connection_is_ssl = true; diff --git a/proxy/http2/Http2ClientSession.h b/proxy/http2/Http2ClientSession.h index dbece267d5e..c4d873ba3eb 100644 --- a/proxy/http2/Http2ClientSession.h +++ b/proxy/http2/Http2ClientSession.h @@ -212,7 +212,7 @@ class Http2ClientSession : public ProxyClientSession virtual int get_transact_count() const { - return (int)con_id; + return connection_state.get_stream_requests(); } virtual void release(ProxyClientTransaction *trans) diff --git a/proxy/http2/Http2ConnectionState.cc b/proxy/http2/Http2ConnectionState.cc index e1fa654b067..afffb5029a3 100644 --- a/proxy/http2/Http2ConnectionState.cc +++ b/proxy/http2/Http2ConnectionState.cc @@ -922,7 +922,9 @@ Http2ConnectionState::create_stream(Http2StreamId new_id) ++total_client_streams_count; new_stream->set_parent(ua_session); - new_stream->mutex = ua_session->mutex; + new_stream->mutex = ua_session->mutex; + new_stream->is_first_transaction_flag = get_stream_requests() == 0; + increment_stream_requests(); ua_session->get_netvc()->add_to_active_queue(); // reset the activity timeout everytime a new stream is created ua_session->get_netvc()->set_active_timeout(HRTIME_SECONDS(Http2::active_timeout_in)); diff --git a/proxy/http2/Http2ConnectionState.h b/proxy/http2/Http2ConnectionState.h index 2ef3453a610..eb6f93025ef 100644 --- a/proxy/http2/Http2ConnectionState.h +++ b/proxy/http2/Http2ConnectionState.h @@ -119,6 +119,7 @@ class Http2ConnectionState : public Continuation stream_list(), latest_streamid_in(0), latest_streamid_out(0), + stream_requests(0), client_streams_in_count(0), client_streams_out_count(0), total_client_streams_count(0), @@ -191,6 +192,18 @@ class Http2ConnectionState : public Continuation return latest_streamid_out; } + int + get_stream_requests() const + { + return stream_requests; + } + + void + increment_stream_requests() + { + stream_requests++; + } + // Continuated header decoding Http2StreamId get_continued_stream_id() const @@ -267,6 +280,7 @@ class Http2ConnectionState : public Continuation DLL stream_list; Http2StreamId latest_streamid_in; Http2StreamId latest_streamid_out; + int stream_requests; // Counter for current active streams which is started by client uint32_t client_streams_in_count; diff --git a/proxy/http2/Http2Stream.h b/proxy/http2/Http2Stream.h index 6aa2dec8742..924275e7c8b 100644 --- a/proxy/http2/Http2Stream.h +++ b/proxy/http2/Http2Stream.h @@ -50,6 +50,7 @@ class Http2Stream : public ProxyClientTransaction sent_request_header(false), response_header_done(false), request_sent(false), + is_first_transaction_flag(false), response_reader(NULL), request_reader(NULL), request_buffer(CLIENT_CONNECTION_FIRST_READ_BUFFER_SIZE_INDEX), @@ -204,6 +205,7 @@ class Http2Stream : public ProxyClientTransaction bool sent_request_header; bool response_header_done; bool request_sent; + bool is_first_transaction_flag; HTTPHdr response_header; IOBufferReader *response_reader; @@ -252,6 +254,12 @@ class Http2Stream : public ProxyClientTransaction return closed; } + bool + is_first_transaction() const + { + return is_first_transaction_flag; + } + private: void response_initialize_data_handling(bool &is_done); void response_process_data(bool &is_done);