This is an automated email from the ASF dual-hosted git repository. zwoop pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/trafficserver.git
commit 3715017cbe8ef08becad05193edd6cebf8785ed0 Author: Aaron Canary <acan...@oath.com> AuthorDate: Fri Aug 23 11:33:04 2019 -0500 ProxySsn renaming member vars to be more accurate and use naming conventions. (cherry picked from commit 7831fb058d8703edd681134dc0574758bac4d3fa) --- .../client-session-architecture.en.rst | 2 +- proxy/ProxyTransaction.cc | 82 +++++++++---------- proxy/ProxyTransaction.h | 6 +- proxy/http/Http1ClientSession.cc | 10 +-- proxy/http/Http1ClientSession.h | 4 +- proxy/http/Http1Transaction.cc | 46 +++++------ proxy/http/HttpUpdateTester.cc | 6 +- proxy/http2/Http2ClientSession.cc | 32 ++++---- proxy/http2/Http2ClientSession.h | 2 +- proxy/http2/Http2ConnectionState.cc | 10 +-- proxy/http2/Http2Stream.cc | 92 +++++++++++----------- proxy/http3/Http3Transaction.cc | 38 ++++----- 12 files changed, 165 insertions(+), 165 deletions(-) diff --git a/doc/developer-guide/client-session-architecture.en.rst b/doc/developer-guide/client-session-architecture.en.rst index fb32a81..65696df 100644 --- a/doc/developer-guide/client-session-architecture.en.rst +++ b/doc/developer-guide/client-session-architecture.en.rst @@ -80,7 +80,7 @@ When the Http1Transaction object is instantiated via :code:`ProxyTransaction::ne new HttpSM object, initializes it, and calls :code:`HttpSM::attach_client_session()` to associate the Http1Transaction object with the new HttpSM. -The ProxyTransaction object refers to the HttpSM via the current_reader member variable. The HttpSM object +The ProxyTransaction object refers to the HttpSM via the _sm member variable. The HttpSM object refers to ProxyTransaction via the ua_session member variable (session in the member name is historical because the HttpSM used to refer directly to the ClientSession object). diff --git a/proxy/ProxyTransaction.cc b/proxy/ProxyTransaction.cc index fb5a49a..47099a9 100644 --- a/proxy/ProxyTransaction.cc +++ b/proxy/ProxyTransaction.cc @@ -32,51 +32,51 @@ ProxyTransaction::ProxyTransaction() : VConnection(nullptr) {} void ProxyTransaction::new_transaction() { - ink_assert(current_reader == nullptr); + ink_assert(_sm == nullptr); // Defensive programming, make sure nothing persists across // connection re-use - ink_release_assert(proxy_ssn != nullptr); - current_reader = HttpSM::allocate(); - current_reader->init(); - HttpTxnDebug("[%" PRId64 "] Starting transaction %d using sm [%" PRId64 "]", proxy_ssn->connection_id(), - proxy_ssn->get_transact_count(), current_reader->sm_id); + ink_release_assert(_proxy_ssn != nullptr); + _sm = HttpSM::allocate(); + _sm->init(); + HttpTxnDebug("[%" PRId64 "] Starting transaction %d using sm [%" PRId64 "]", _proxy_ssn->connection_id(), + _proxy_ssn->get_transact_count(), _sm->sm_id); PluginIdentity *pi = dynamic_cast<PluginIdentity *>(this->get_netvc()); if (pi) { - current_reader->plugin_tag = pi->getPluginTag(); - current_reader->plugin_id = pi->getPluginId(); + _sm->plugin_tag = pi->getPluginTag(); + _sm->plugin_id = pi->getPluginId(); } this->increment_client_transactions_stat(); - current_reader->attach_client_session(this, sm_reader); + _sm->attach_client_session(this, _reader); } void ProxyTransaction::release(IOBufferReader *r) { - HttpTxnDebug("[%" PRId64 "] session released by sm [%" PRId64 "]", proxy_ssn ? proxy_ssn->connection_id() : 0, - current_reader ? current_reader->sm_id : 0); + HttpTxnDebug("[%" PRId64 "] session released by sm [%" PRId64 "]", _proxy_ssn ? _proxy_ssn->connection_id() : 0, + _sm ? _sm->sm_id : 0); this->decrement_client_transactions_stat(); // Pass along the release to the session - if (proxy_ssn) { - proxy_ssn->release(this); + if (_proxy_ssn) { + _proxy_ssn->release(this); } } void ProxyTransaction::attach_server_session(Http1ServerSession *ssession, bool transaction_done) { - proxy_ssn->attach_server_session(ssession, transaction_done); + _proxy_ssn->attach_server_session(ssession, transaction_done); } void ProxyTransaction::destroy() { - current_reader = nullptr; + _sm = nullptr; this->mutex.clear(); } @@ -100,29 +100,29 @@ ProxyTransaction::adjust_thread(Continuation *cont, int event, void *data) void ProxyTransaction::set_rx_error_code(ProxyError e) { - if (this->current_reader) { - this->current_reader->t_state.client_info.rx_error_code = e; + if (this->_sm) { + this->_sm->t_state.client_info.rx_error_code = e; } } void ProxyTransaction::set_tx_error_code(ProxyError e) { - if (this->current_reader) { - this->current_reader->t_state.client_info.tx_error_code = e; + if (this->_sm) { + this->_sm->t_state.client_info.tx_error_code = e; } } NetVConnection * ProxyTransaction::get_netvc() const { - return (proxy_ssn) ? proxy_ssn->get_netvc() : nullptr; + return (_proxy_ssn) ? _proxy_ssn->get_netvc() : nullptr; } bool ProxyTransaction::is_first_transaction() const { - return proxy_ssn->get_transact_count() == 1; + return _proxy_ssn->get_transact_count() == 1; } // Ask your session if this is allowed bool @@ -134,21 +134,21 @@ ProxyTransaction::is_transparent_passthrough_allowed() bool ProxyTransaction::is_chunked_encoding_supported() const { - return proxy_ssn ? proxy_ssn->is_chunked_encoding_supported() : false; + return _proxy_ssn ? _proxy_ssn->is_chunked_encoding_supported() : false; } void ProxyTransaction::set_half_close_flag(bool flag) { - if (proxy_ssn) { - proxy_ssn->set_half_close_flag(flag); + if (_proxy_ssn) { + _proxy_ssn->set_half_close_flag(flag); } } bool ProxyTransaction::get_half_close_flag() const { - return proxy_ssn ? proxy_ssn->get_half_close_flag() : false; + return _proxy_ssn ? _proxy_ssn->get_half_close_flag() : false; } // What are the debug and hooks_enabled used for? How are they set? @@ -156,47 +156,47 @@ ProxyTransaction::get_half_close_flag() const bool ProxyTransaction::debug() const { - return proxy_ssn ? proxy_ssn->debug() : false; + return _proxy_ssn ? _proxy_ssn->debug() : false; } APIHook * ProxyTransaction::hook_get(TSHttpHookID id) const { - return proxy_ssn ? proxy_ssn->hook_get(id) : nullptr; + return _proxy_ssn ? _proxy_ssn->hook_get(id) : nullptr; } HttpAPIHooks const * ProxyTransaction::feature_hooks() const { - return proxy_ssn ? proxy_ssn->feature_hooks() : nullptr; + return _proxy_ssn ? _proxy_ssn->feature_hooks() : nullptr; } bool ProxyTransaction::has_hooks() const { - return proxy_ssn->has_hooks(); + return _proxy_ssn->has_hooks(); } void ProxyTransaction::set_session_active() { - if (proxy_ssn) { - proxy_ssn->set_session_active(); + if (_proxy_ssn) { + _proxy_ssn->set_session_active(); } } void ProxyTransaction::clear_session_active() { - if (proxy_ssn) { - proxy_ssn->clear_session_active(); + if (_proxy_ssn) { + _proxy_ssn->clear_session_active(); } } const IpAllow::ACL & ProxyTransaction::get_acl() const { - return proxy_ssn ? proxy_ssn->acl : IpAllow::DENY_ALL_ACL; + return _proxy_ssn ? _proxy_ssn->acl : IpAllow::DENY_ALL_ACL; } // outbound values Set via the server port definition. Really only used for Http1 at the moment @@ -250,13 +250,13 @@ ProxyTransaction::set_outbound_transparent(bool flag) ProxySession * ProxyTransaction::get_proxy_ssn() { - return proxy_ssn; + return _proxy_ssn; } void ProxyTransaction::set_proxy_ssn(ProxySession *new_proxy_ssn) { - proxy_ssn = new_proxy_ssn; + _proxy_ssn = new_proxy_ssn; } void @@ -267,29 +267,29 @@ ProxyTransaction::set_h2c_upgrade_flag() Http1ServerSession * ProxyTransaction::get_server_session() const { - return proxy_ssn ? proxy_ssn->get_server_session() : nullptr; + return _proxy_ssn ? _proxy_ssn->get_server_session() : nullptr; } HttpSM * ProxyTransaction::get_sm() const { - return current_reader; + return _sm; } const char * ProxyTransaction::get_protocol_string() { - return proxy_ssn ? proxy_ssn->get_protocol_string() : nullptr; + return _proxy_ssn ? _proxy_ssn->get_protocol_string() : nullptr; } int ProxyTransaction::populate_protocol(std::string_view *result, int size) const { - return proxy_ssn ? proxy_ssn->populate_protocol(result, size) : 0; + return _proxy_ssn ? _proxy_ssn->populate_protocol(result, size) : 0; } const char * ProxyTransaction::protocol_contains(std::string_view tag_prefix) const { - return proxy_ssn ? proxy_ssn->protocol_contains(tag_prefix) : nullptr; + return _proxy_ssn ? _proxy_ssn->protocol_contains(tag_prefix) : nullptr; } diff --git a/proxy/ProxyTransaction.h b/proxy/ProxyTransaction.h index d40e559..47999df 100644 --- a/proxy/ProxyTransaction.h +++ b/proxy/ProxyTransaction.h @@ -113,9 +113,9 @@ public: HttpSessionAccept::Options upstream_outbound_options; // overwritable copy of options protected: - ProxySession *proxy_ssn = nullptr; - HttpSM *current_reader = nullptr; - IOBufferReader *sm_reader = nullptr; + ProxySession *_proxy_ssn = nullptr; + HttpSM *_sm = nullptr; + IOBufferReader *_reader = nullptr; private: }; diff --git a/proxy/http/Http1ClientSession.cc b/proxy/http/Http1ClientSession.cc index 87edda3..d5b2269 100644 --- a/proxy/http/Http1ClientSession.cc +++ b/proxy/http/Http1ClientSession.cc @@ -186,8 +186,8 @@ Http1ClientSession::new_connection(NetVConnection *new_vc, MIOBuffer *iobuf, IOB client_vc->set_tcp_congestion_control(CLIENT_SIDE); read_buffer = iobuf ? iobuf : new_MIOBuffer(HTTP_HEADER_BUFFER_SIZE_INDEX); - sm_reader = reader ? reader : read_buffer->alloc_reader(); - trans.set_reader(sm_reader); + _reader = reader ? reader : read_buffer->alloc_reader(); + trans.set_reader(_reader); // INKqa11186: Use a local pointer to the mutex as // when we return from do_api_callout, the ClientSession may @@ -272,7 +272,7 @@ Http1ClientSession::do_io_close(int alerrno) // [bug 2610799] Drain any data read. // If the buffer is full and the client writes again, we will not receive a // READ_READY event. - sm_reader->consume(sm_reader->read_avail()); + _reader->consume(_reader->read_avail()); } else { read_state = HCS_CLOSED; HttpSsnDebug("[%" PRId64 "] session closed", con_id); @@ -312,7 +312,7 @@ Http1ClientSession::state_wait_for_close(int event, void *data) break; case VC_EVENT_READ_READY: // Drain any data read - sm_reader->consume(sm_reader->read_avail()); + _reader->consume(_reader->read_avail()); break; default: @@ -421,7 +421,7 @@ Http1ClientSession::release(ProxyTransaction *trans) // buffer. If there is, spin up a new state // machine to process it. Otherwise, issue an // IO to wait for new data - bool more_to_read = this->sm_reader->is_read_avail_more_than(0); + bool more_to_read = this->_reader->is_read_avail_more_than(0); if (more_to_read) { trans->destroy(); HttpSsnDebug("[%" PRId64 "] data already in buffer, starting new transaction", con_id); diff --git a/proxy/http/Http1ClientSession.h b/proxy/http/Http1ClientSession.h index 7403d42..fd9afda 100644 --- a/proxy/http/Http1ClientSession.h +++ b/proxy/http/Http1ClientSession.h @@ -112,8 +112,8 @@ private: bool half_close = false; bool conn_decrease = false; - MIOBuffer *read_buffer = nullptr; - IOBufferReader *sm_reader = nullptr; + MIOBuffer *read_buffer = nullptr; + IOBufferReader *_reader = nullptr; C_Read_State read_state = HCS_INIT; diff --git a/proxy/http/Http1Transaction.cc b/proxy/http/Http1Transaction.cc index e69991e..73a161b 100644 --- a/proxy/http/Http1Transaction.cc +++ b/proxy/http/Http1Transaction.cc @@ -30,16 +30,16 @@ Http1Transaction::release(IOBufferReader *r) { // Must set this inactivity count here rather than in the session because the state machine // is not available then - MgmtInt ka_in = current_reader->t_state.txn_conf->keep_alive_no_activity_timeout_in; + MgmtInt ka_in = _sm->t_state.txn_conf->keep_alive_no_activity_timeout_in; set_inactivity_timeout(HRTIME_SECONDS(ka_in)); - proxy_ssn->clear_session_active(); - proxy_ssn->ssn_last_txn_time = Thread::get_hrtime(); + _proxy_ssn->clear_session_active(); + _proxy_ssn->ssn_last_txn_time = Thread::get_hrtime(); // Make sure that the state machine is returning // correct buffer reader - ink_assert(r == sm_reader); - if (r != sm_reader) { + ink_assert(r == _reader); + if (r != _reader) { this->do_io_close(); } else { super_type::release(r); @@ -48,30 +48,30 @@ Http1Transaction::release(IOBufferReader *r) void Http1Transaction::destroy() // todo make ~Http1Transaction() { - current_reader = nullptr; + _sm = nullptr; } void Http1Transaction::transaction_done() { - if (proxy_ssn) { - static_cast<Http1ClientSession *>(proxy_ssn)->release_transaction(); + if (_proxy_ssn) { + static_cast<Http1ClientSession *>(_proxy_ssn)->release_transaction(); } } void Http1Transaction::reenable(VIO *vio) { - proxy_ssn->reenable(vio); + _proxy_ssn->reenable(vio); } bool Http1Transaction::allow_half_open() const { - bool config_allows_it = (current_reader) ? current_reader->t_state.txn_conf->allow_half_open > 0 : true; + bool config_allows_it = (_sm) ? _sm->t_state.txn_conf->allow_half_open > 0 : true; if (config_allows_it) { // Check with the session to make sure the underlying transport allows the half open scenario - return static_cast<Http1ClientSession *>(proxy_ssn)->allow_half_open(); + return static_cast<Http1ClientSession *>(_proxy_ssn)->allow_half_open(); } return false; } @@ -92,50 +92,50 @@ Http1Transaction::decrement_client_transactions_stat() VIO * Http1Transaction::do_io_read(Continuation *c, int64_t nbytes, MIOBuffer *buf) { - return proxy_ssn->do_io_read(c, nbytes, buf); + return _proxy_ssn->do_io_read(c, nbytes, buf); } VIO * Http1Transaction::do_io_write(Continuation *c, int64_t nbytes, IOBufferReader *buf, bool owner) { - return proxy_ssn->do_io_write(c, nbytes, buf, owner); + return _proxy_ssn->do_io_write(c, nbytes, buf, owner); } void Http1Transaction::do_io_close(int lerrno) { - proxy_ssn->do_io_close(lerrno); + _proxy_ssn->do_io_close(lerrno); // this->destroy(); Parent owns this data structure. No need for separate destroy. } void Http1Transaction::do_io_shutdown(ShutdownHowTo_t howto) { - proxy_ssn->do_io_shutdown(howto); + _proxy_ssn->do_io_shutdown(howto); } void Http1Transaction::set_reader(IOBufferReader *reader) { - sm_reader = reader; + _reader = reader; } void Http1Transaction::set_active_timeout(ink_hrtime timeout_in) { - if (proxy_ssn) - proxy_ssn->set_active_timeout(timeout_in); + if (_proxy_ssn) + _proxy_ssn->set_active_timeout(timeout_in); } void Http1Transaction::set_inactivity_timeout(ink_hrtime timeout_in) { - if (proxy_ssn) - proxy_ssn->set_inactivity_timeout(timeout_in); + if (_proxy_ssn) + _proxy_ssn->set_inactivity_timeout(timeout_in); } void Http1Transaction::cancel_inactivity_timeout() { - if (proxy_ssn) - proxy_ssn->cancel_inactivity_timeout(); + if (_proxy_ssn) + _proxy_ssn->cancel_inactivity_timeout(); } // int @@ -145,5 +145,5 @@ Http1Transaction::get_transaction_id() const // presumed not to increase during the lifetime of a transaction, thus this function will return a consistent unique transaction // identifier. // - return proxy_ssn->get_transact_count(); + return _proxy_ssn->get_transact_count(); } diff --git a/proxy/http/HttpUpdateTester.cc b/proxy/http/HttpUpdateTester.cc index 581eafb..3841aa2 100644 --- a/proxy/http/HttpUpdateTester.cc +++ b/proxy/http/HttpUpdateTester.cc @@ -87,9 +87,9 @@ UpTest::make_requests() test_req.parse_req(&http_parser, &req, req + strlen(req), false); http_parser_clear(&http_parser); - HttpUpdateSM *current_reader = HttpUpdateSM::allocate(); - current_reader->init(); - Action *a = current_reader->start_scheduled_update(this, test_req); + HttpUpdateSM *_sm = HttpUpdateSM::allocate(); + _sm->init(); + Action *a = _sm->start_scheduled_update(this, test_req); (void)a; active_req++; diff --git a/proxy/http2/Http2ClientSession.cc b/proxy/http2/Http2ClientSession.cc index f52155c..3f75486 100644 --- a/proxy/http2/Http2ClientSession.cc +++ b/proxy/http2/Http2ClientSession.cc @@ -176,7 +176,7 @@ Http2ClientSession::start() this->connection_state.init(); send_connection_event(&this->connection_state, HTTP2_SESSION_EVENT_INIT, this); - if (this->sm_reader->is_read_avail_more_than(0)) { + if (this->_reader->is_read_avail_more_than(0)) { this->handleEvent(VC_EVENT_READ_READY, read_vio); } } @@ -205,7 +205,7 @@ Http2ClientSession::new_connection(NetVConnection *new_vc, MIOBuffer *iobuf, IOB this->read_buffer = iobuf ? iobuf : new_MIOBuffer(HTTP2_HEADER_BUFFER_SIZE_INDEX); this->read_buffer->water_mark = connection_state.server_settings.get(HTTP2_SETTINGS_MAX_FRAME_SIZE); - this->sm_reader = reader ? reader : this->read_buffer->alloc_reader(); + this->_reader = reader ? reader : this->read_buffer->alloc_reader(); this->write_buffer = new_MIOBuffer(HTTP2_HEADER_BUFFER_SIZE_INDEX); this->sm_writer = this->write_buffer->alloc_reader(); @@ -430,11 +430,11 @@ Http2ClientSession::state_read_connection_preface(int event, void *edata) STATE_ENTER(&Http2ClientSession::state_read_connection_preface, event); ink_assert(event == VC_EVENT_READ_COMPLETE || event == VC_EVENT_READ_READY); - if (this->sm_reader->read_avail() >= static_cast<int64_t>(HTTP2_CONNECTION_PREFACE_LEN)) { + if (this->_reader->read_avail() >= static_cast<int64_t>(HTTP2_CONNECTION_PREFACE_LEN)) { char buf[HTTP2_CONNECTION_PREFACE_LEN]; unsigned nbytes; - nbytes = copy_from_buffer_reader(buf, this->sm_reader, sizeof(buf)); + nbytes = copy_from_buffer_reader(buf, this->_reader, sizeof(buf)); ink_release_assert(nbytes == HTTP2_CONNECTION_PREFACE_LEN); if (memcmp(HTTP2_CONNECTION_PREFACE, buf, nbytes) != 0) { @@ -444,7 +444,7 @@ Http2ClientSession::state_read_connection_preface(int event, void *edata) } Http2SsnDebug("received connection preface"); - this->sm_reader->consume(nbytes); + this->_reader->consume(nbytes); HTTP2_SET_SESSION_HANDLER(&Http2ClientSession::state_start_frame_read); client_vc->set_inactivity_timeout(HRTIME_SECONDS(Http2::no_activity_timeout_in)); @@ -453,7 +453,7 @@ Http2ClientSession::state_read_connection_preface(int event, void *edata) // XXX start the write VIO ... // If we have unconsumed data, start tranferring frames now. - if (this->sm_reader->is_read_avail_more_than(0)) { + if (this->_reader->is_read_avail_more_than(0)) { return this->handleEvent(VC_EVENT_READ_READY, vio); } } @@ -481,13 +481,13 @@ int Http2ClientSession::do_start_frame_read(Http2ErrorCode &ret_error) { ret_error = Http2ErrorCode::HTTP2_ERROR_NO_ERROR; - ink_release_assert(this->sm_reader->read_avail() >= (int64_t)HTTP2_FRAME_HEADER_LEN); + ink_release_assert(this->_reader->read_avail() >= (int64_t)HTTP2_FRAME_HEADER_LEN); uint8_t buf[HTTP2_FRAME_HEADER_LEN]; unsigned nbytes; Http2SsnDebug("receiving frame header"); - nbytes = copy_from_buffer_reader(buf, this->sm_reader, sizeof(buf)); + nbytes = copy_from_buffer_reader(buf, this->_reader, sizeof(buf)); if (!http2_parse_frame_header(make_iovec(buf), this->current_hdr)) { Http2SsnDebug("frame header parse failure"); @@ -498,7 +498,7 @@ Http2ClientSession::do_start_frame_read(Http2ErrorCode &ret_error) Http2SsnDebug("frame header length=%u, type=%u, flags=0x%x, streamid=%u", (unsigned)this->current_hdr.length, (unsigned)this->current_hdr.type, (unsigned)this->current_hdr.flags, this->current_hdr.streamid); - this->sm_reader->consume(nbytes); + this->_reader->consume(nbytes); if (!http2_frame_header_is_valid(this->current_hdr, this->connection_state.server_settings.get(HTTP2_SETTINGS_MAX_FRAME_SIZE))) { ret_error = Http2ErrorCode::HTTP2_ERROR_PROTOCOL_ERROR; @@ -528,7 +528,7 @@ Http2ClientSession::state_complete_frame_read(int event, void *edata) VIO *vio = static_cast<VIO *>(edata); STATE_ENTER(&Http2ClientSession::state_complete_frame_read, event); ink_assert(event == VC_EVENT_READ_COMPLETE || event == VC_EVENT_READ_READY); - if (this->sm_reader->read_avail() < this->current_hdr.length) { + if (this->_reader->read_avail() < this->current_hdr.length) { if (this->_should_do_something_else()) { if (this->_reenable_event == nullptr) { vio->disable(); @@ -541,7 +541,7 @@ Http2ClientSession::state_complete_frame_read(int event, void *edata) } return 0; } - Http2SsnDebug("completed frame read, %" PRId64 " bytes available", this->sm_reader->read_avail()); + Http2SsnDebug("completed frame read, %" PRId64 " bytes available", this->_reader->read_avail()); return state_process_frame_read(event, vio, true); } @@ -550,11 +550,11 @@ int Http2ClientSession::do_complete_frame_read() { // XXX parse the frame and handle it ... - ink_release_assert(this->sm_reader->read_avail() >= this->current_hdr.length); + ink_release_assert(this->_reader->read_avail() >= this->current_hdr.length); - Http2Frame frame(this->current_hdr, this->sm_reader); + Http2Frame frame(this->current_hdr, this->_reader); send_connection_event(&this->connection_state, HTTP2_SESSION_EVENT_RECV, &frame); - this->sm_reader->consume(this->current_hdr.length); + this->_reader->consume(this->current_hdr.length); ++(this->_n_frame_read); // Set the event handler if there is no more data to process a new frame @@ -570,7 +570,7 @@ Http2ClientSession::state_process_frame_read(int event, VIO *vio, bool inside_fr do_complete_frame_read(); } - while (this->sm_reader->read_avail() >= static_cast<int64_t>(HTTP2_FRAME_HEADER_LEN)) { + while (this->_reader->read_avail() >= static_cast<int64_t>(HTTP2_FRAME_HEADER_LEN)) { // Cancel reading if there was an error or connection is closed if (connection_state.tx_error_code.code != static_cast<uint32_t>(Http2ErrorCode::HTTP2_ERROR_NO_ERROR) || connection_state.is_state_closed()) { @@ -603,7 +603,7 @@ Http2ClientSession::state_process_frame_read(int event, VIO *vio, bool inside_fr } // If there is no more data to finish the frame, set up the event handler and reenable - if (this->sm_reader->read_avail() < this->current_hdr.length) { + if (this->_reader->read_avail() < this->current_hdr.length) { HTTP2_SET_SESSION_HANDLER(&Http2ClientSession::state_complete_frame_read); break; } diff --git a/proxy/http2/Http2ClientSession.h b/proxy/http2/Http2ClientSession.h index 48df0f0..0bb9755 100644 --- a/proxy/http2/Http2ClientSession.h +++ b/proxy/http2/Http2ClientSession.h @@ -239,7 +239,7 @@ private: SessionHandler session_handler = nullptr; NetVConnection *client_vc = nullptr; MIOBuffer *read_buffer = nullptr; - IOBufferReader *sm_reader = nullptr; + IOBufferReader *_reader = nullptr; MIOBuffer *write_buffer = nullptr; IOBufferReader *sm_writer = nullptr; Http2FrameHeader current_hdr = {0, 0, 0, 0}; diff --git a/proxy/http2/Http2ConnectionState.cc b/proxy/http2/Http2ConnectionState.cc index ddf39ed..7fb41ce 100644 --- a/proxy/http2/Http2ConnectionState.cc +++ b/proxy/http2/Http2ConnectionState.cc @@ -1451,17 +1451,17 @@ Http2ConnectionState::send_a_data_frame(Http2Stream *stream, size_t &payload_len uint8_t flags = 0x00; uint8_t payload_buffer[buf_len]; - IOBufferReader *current_reader = stream->response_get_data_reader(); + IOBufferReader *_sm = stream->response_get_data_reader(); SCOPED_MUTEX_LOCK(stream_lock, stream->mutex, this_ethread()); - if (!current_reader) { + if (!_sm) { Http2StreamDebug(this->ua_session, stream->get_id(), "couldn't get data reader"); return Http2SendDataFrameResult::ERROR; } // Select appropriate payload length - if (current_reader->is_read_avail_more_than(0)) { + if (_sm->is_read_avail_more_than(0)) { // We only need to check for window size when there is a payload if (window_size <= 0) { Http2StreamDebug(this->ua_session, stream->get_id(), "No window"); @@ -1469,7 +1469,7 @@ Http2ConnectionState::send_a_data_frame(Http2Stream *stream, size_t &payload_len } // Copy into the payload buffer. Seems like we should be able to skip this copy step payload_length = write_available_size; - payload_length = current_reader->read(payload_buffer, static_cast<int64_t>(write_available_size)); + payload_length = _sm->read(payload_buffer, static_cast<int64_t>(write_available_size)); } else { payload_length = 0; } @@ -1482,7 +1482,7 @@ Http2ConnectionState::send_a_data_frame(Http2Stream *stream, size_t &payload_len return Http2SendDataFrameResult::NO_PAYLOAD; } - if (stream->is_body_done() && !current_reader->is_read_avail_more_than(0)) { + if (stream->is_body_done() && !_sm->is_read_avail_more_than(0)) { flags |= HTTP2_FLAGS_DATA_END_STREAM; } diff --git a/proxy/http2/Http2Stream.cc b/proxy/http2/Http2Stream.cc index 2694a33..e4d6542 100644 --- a/proxy/http2/Http2Stream.cc +++ b/proxy/http2/Http2Stream.cc @@ -34,7 +34,7 @@ } #define Http2StreamDebug(fmt, ...) \ - SsnDebug(proxy_ssn, "http2_stream", "[%" PRId64 "] [%u] " fmt, proxy_ssn->connection_id(), this->get_id(), ##__VA_ARGS__); + SsnDebug(_proxy_ssn, "http2_stream", "[%" PRId64 "] [%u] " fmt, _proxy_ssn->connection_id(), this->get_id(), ##__VA_ARGS__); ClassAllocator<Http2Stream> http2StreamAllocator("http2StreamAllocator"); @@ -52,7 +52,7 @@ Http2Stream::init(Http2StreamId sid, ssize_t initial_rwnd) this->_thread = this_ethread(); this->_client_rwnd = initial_rwnd; - sm_reader = request_reader = request_buffer.alloc_reader(); + _reader = request_reader = request_buffer.alloc_reader(); // FIXME: Are you sure? every "stream" needs request_header? _req_header.create(HTTP_TYPE_REQUEST); response_header.create(HTTP_TYPE_RESPONSE); @@ -94,7 +94,7 @@ Http2Stream::main_event_handler(int event, void *edata) switch (event) { case VC_EVENT_ACTIVE_TIMEOUT: case VC_EVENT_INACTIVITY_TIMEOUT: - if (current_reader && read_vio.ntodo() > 0) { + if (_sm && read_vio.ntodo() > 0) { MUTEX_TRY_LOCK(lock, read_vio.mutex, this_ethread()); if (lock.is_locked()) { read_vio.cont->handleEvent(event, &read_vio); @@ -104,7 +104,7 @@ Http2Stream::main_event_handler(int event, void *edata) } this->_read_vio_event = this_ethread()->schedule_imm(read_vio.cont, event, &read_vio); } - } else if (current_reader && write_vio.ntodo() > 0) { + } else if (_sm && write_vio.ntodo() > 0) { MUTEX_TRY_LOCK(lock, write_vio.mutex, this_ethread()); if (lock.is_locked()) { write_vio.cont->handleEvent(event, &write_vio); @@ -120,7 +120,7 @@ Http2Stream::main_event_handler(int event, void *edata) case VC_EVENT_WRITE_COMPLETE: inactive_timeout_at = Thread::get_hrtime() + inactive_timeout; if (e->cookie == &write_vio) { - if (write_vio.mutex && write_vio.cont && this->current_reader) { + if (write_vio.mutex && write_vio.cont && this->_sm) { MUTEX_TRY_LOCK(lock, write_vio.mutex, this_ethread()); if (lock.is_locked()) { write_vio.cont->handleEvent(event, &write_vio); @@ -139,7 +139,7 @@ Http2Stream::main_event_handler(int event, void *edata) case VC_EVENT_READ_READY: inactive_timeout_at = Thread::get_hrtime() + inactive_timeout; if (e->cookie == &read_vio) { - if (read_vio.mutex && read_vio.cont && this->current_reader) { + if (read_vio.mutex && read_vio.cont && this->_sm) { MUTEX_TRY_LOCK(lock, read_vio.mutex, this_ethread()); if (lock.is_locked()) { read_vio.cont->handleEvent(event, &read_vio); @@ -181,8 +181,8 @@ Http2Stream::decode_header_blocks(HpackHandle &hpack_handle, uint32_t maximum_ta void Http2Stream::send_request(Http2ConnectionState &cstate) { - ink_release_assert(this->current_reader != nullptr); - this->_http_sm_id = this->current_reader->sm_id; + ink_release_assert(this->_sm != nullptr); + this->_http_sm_id = this->_sm->sm_id; // Convert header to HTTP/1.1 format http2_convert_header_from_2_to_1_1(&_req_header); @@ -374,10 +374,10 @@ Http2Stream::do_io_close(int /* flags */) // by the time this is called from transaction_done. closed = true; - if (proxy_ssn && this->is_client_state_writeable()) { + if (_proxy_ssn && this->is_client_state_writeable()) { // Make sure any trailing end of stream frames are sent // Wee will be removed at send_data_frames or closing connection phase - static_cast<Http2ClientSession *>(proxy_ssn)->connection_state.send_data_frames(this); + static_cast<Http2ClientSession *>(_proxy_ssn)->connection_state.send_data_frames(this); } clear_timers(); @@ -400,10 +400,10 @@ Http2Stream::transaction_done() } if (!closed) { - do_io_close(); // Make sure we've been closed. If we didn't close the proxy_ssn session better still be open + do_io_close(); // Make sure we've been closed. If we didn't close the _proxy_ssn session better still be open } - ink_release_assert(closed || !static_cast<Http2ClientSession *>(proxy_ssn)->connection_state.is_state_closed()); - current_reader = nullptr; + ink_release_assert(closed || !static_cast<Http2ClientSession *>(_proxy_ssn)->connection_state.is_state_closed()); + _sm = nullptr; if (closed) { // Safe to initiate SSN_CLOSE if this is the last stream @@ -420,7 +420,7 @@ Http2Stream::terminate_if_possible() if (terminate_stream && reentrancy_count == 0) { REMEMBER(NO_EVENT, this->reentrancy_count); - Http2ClientSession *h2_parent = static_cast<Http2ClientSession *>(proxy_ssn); + Http2ClientSession *h2_parent = static_cast<Http2ClientSession *>(_proxy_ssn); SCOPED_MUTEX_LOCK(lock, h2_parent->connection_state.mutex, this_ethread()); h2_parent->connection_state.delete_stream(this); destroy(); @@ -442,10 +442,10 @@ Http2Stream::initiating_close() _state = Http2StreamState::HTTP2_STREAM_STATE_CLOSED; // leaving the reference to the SM, so we can detach from the SM when we actually destroy - // current_reader = NULL; + // _sm = NULL; // Leaving reference to client session as well, so we can signal once the // TXN_CLOSE has been sent - // proxy_ssn = NULL; + // _proxy_ssn = NULL; clear_timers(); clear_io_events(); @@ -456,7 +456,7 @@ Http2Stream::initiating_close() // We are sending signals rather than calling the handlers directly to avoid the case where // the HttpTunnel handler causes the HttpSM to be deleted on the stack. bool sent_write_complete = false; - if (current_reader) { + if (_sm) { // Push out any last IO events if (write_vio.cont) { SCOPED_MUTEX_LOCK(lock, write_vio.mutex, this_ethread()); @@ -472,16 +472,16 @@ Http2Stream::initiating_close() } } // Send EOS to let SM know that we aren't sticking around - if (current_reader && read_vio.cont) { + if (_sm && read_vio.cont) { // Only bother with the EOS if we haven't sent the write complete if (!sent_write_complete) { SCOPED_MUTEX_LOCK(lock, read_vio.mutex, this_ethread()); Http2StreamDebug("send EOS to read cont"); read_event = send_tracked_event(read_event, VC_EVENT_EOS, &read_vio); } - } else if (current_reader) { - SCOPED_MUTEX_LOCK(lock, current_reader->mutex, this_ethread()); - current_reader->handleEvent(VC_EVENT_ERROR); + } else if (_sm) { + SCOPED_MUTEX_LOCK(lock, _sm->mutex, this_ethread()); + _sm->handleEvent(VC_EVENT_ERROR); } else if (!sent_write_complete) { // Transaction is already gone or not started. Kill yourself do_io_close(); @@ -512,7 +512,7 @@ Http2Stream::send_tracked_event(Event *event, int send_event, VIO *vio) void Http2Stream::update_read_request(int64_t read_len, bool call_update, bool check_eos) { - if (closed || proxy_ssn == nullptr || current_reader == nullptr || read_vio.mutex == nullptr) { + if (closed || _proxy_ssn == nullptr || _sm == nullptr || read_vio.mutex == nullptr) { return; } @@ -539,7 +539,7 @@ Http2Stream::update_read_request(int64_t read_len, bool call_update, bool check_ int send_event = (read_vio.nbytes == read_vio.ndone || recv_end_stream) ? VC_EVENT_READ_COMPLETE : VC_EVENT_READ_READY; if (call_update) { // Safe to call vio handler directly inactive_timeout_at = Thread::get_hrtime() + inactive_timeout; - if (read_vio.cont && this->current_reader) { + if (read_vio.cont && this->_sm) { read_vio.cont->handleEvent(send_event, &read_vio); } } else { // Called from do_io_read. Still setting things up. Send event to handle this after the dust settles @@ -553,7 +553,7 @@ Http2Stream::update_read_request(int64_t read_len, bool call_update, bool check_ if (request_reader->read_avail() > 0 || send_event == VC_EVENT_READ_COMPLETE) { if (call_update) { // Safe to call vio handler directly inactive_timeout_at = Thread::get_hrtime() + inactive_timeout; - if (read_vio.cont && this->current_reader) { + if (read_vio.cont && this->_sm) { read_vio.cont->handleEvent(send_event, &read_vio); } } else { // Called from do_io_read. Still setting things up. Send event @@ -574,7 +574,7 @@ Http2Stream::restart_sending() void Http2Stream::update_write_request(IOBufferReader *buf_reader, int64_t write_len, bool call_update) { - if (!this->is_client_state_writeable() || closed || proxy_ssn == nullptr || write_vio.mutex == nullptr || + if (!this->is_client_state_writeable() || closed || _proxy_ssn == nullptr || write_vio.mutex == nullptr || (buf_reader == nullptr && write_len == 0)) { return; } @@ -585,7 +585,7 @@ Http2Stream::update_write_request(IOBufferReader *buf_reader, int64_t write_len, } ink_release_assert(this->_thread == this_ethread()); - Http2ClientSession *proxy_ssn = static_cast<Http2ClientSession *>(this->get_proxy_ssn()); + Http2ClientSession *_proxy_ssn = static_cast<Http2ClientSession *>(this->get_proxy_ssn()); SCOPED_MUTEX_LOCK(lock, write_vio.mutex, this_ethread()); @@ -641,17 +641,17 @@ Http2Stream::update_write_request(IOBufferReader *buf_reader, int64_t write_len, int len; const char *value = field->value_get(&len); if (memcmp(HTTP_VALUE_CLOSE, value, HTTP_LEN_CLOSE) == 0) { - SCOPED_MUTEX_LOCK(lock, proxy_ssn->connection_state.mutex, this_ethread()); - if (proxy_ssn->connection_state.get_shutdown_state() == HTTP2_SHUTDOWN_NONE) { - proxy_ssn->connection_state.set_shutdown_state(HTTP2_SHUTDOWN_NOT_INITIATED, Http2ErrorCode::HTTP2_ERROR_NO_ERROR); + SCOPED_MUTEX_LOCK(lock, _proxy_ssn->connection_state.mutex, this_ethread()); + if (_proxy_ssn->connection_state.get_shutdown_state() == HTTP2_SHUTDOWN_NONE) { + _proxy_ssn->connection_state.set_shutdown_state(HTTP2_SHUTDOWN_NOT_INITIATED, Http2ErrorCode::HTTP2_ERROR_NO_ERROR); } } } { - SCOPED_MUTEX_LOCK(lock, proxy_ssn->connection_state.mutex, this_ethread()); + SCOPED_MUTEX_LOCK(lock, _proxy_ssn->connection_state.mutex, this_ethread()); // Send the response header back - proxy_ssn->connection_state.send_headers_frame(this); + _proxy_ssn->connection_state.send_headers_frame(this); } // See if the response is chunked. Set up the dechunking logic if it is @@ -702,7 +702,7 @@ Http2Stream::signal_write_event(bool call_update) if (call_update) { // Coming from reenable. Safe to call the handler directly - if (write_vio.cont && this->current_reader) { + if (write_vio.cont && this->_sm) { write_vio.cont->handleEvent(send_event, &write_vio); } } else { @@ -714,25 +714,25 @@ Http2Stream::signal_write_event(bool call_update) void Http2Stream::push_promise(URL &url, const MIMEField *accept_encoding) { - Http2ClientSession *proxy_ssn = static_cast<Http2ClientSession *>(this->get_proxy_ssn()); - SCOPED_MUTEX_LOCK(lock, proxy_ssn->connection_state.mutex, this_ethread()); - proxy_ssn->connection_state.send_push_promise_frame(this, url, accept_encoding); + Http2ClientSession *_proxy_ssn = static_cast<Http2ClientSession *>(this->get_proxy_ssn()); + SCOPED_MUTEX_LOCK(lock, _proxy_ssn->connection_state.mutex, this_ethread()); + _proxy_ssn->connection_state.send_push_promise_frame(this, url, accept_encoding); } void Http2Stream::send_response_body(bool call_update) { - Http2ClientSession *proxy_ssn = static_cast<Http2ClientSession *>(this->get_proxy_ssn()); - inactive_timeout_at = Thread::get_hrtime() + inactive_timeout; + Http2ClientSession *_proxy_ssn = static_cast<Http2ClientSession *>(this->get_proxy_ssn()); + inactive_timeout_at = Thread::get_hrtime() + inactive_timeout; if (Http2::stream_priority_enabled) { - SCOPED_MUTEX_LOCK(lock, proxy_ssn->connection_state.mutex, this_ethread()); - proxy_ssn->connection_state.schedule_stream(this); + SCOPED_MUTEX_LOCK(lock, _proxy_ssn->connection_state.mutex, this_ethread()); + _proxy_ssn->connection_state.schedule_stream(this); // signal_write_event() will be called from `Http2ConnectionState::send_data_frames_depends_on_priority()` // when write_vio is consumed } else { - SCOPED_MUTEX_LOCK(lock, proxy_ssn->connection_state.mutex, this_ethread()); - proxy_ssn->connection_state.send_data_frames(this); + SCOPED_MUTEX_LOCK(lock, _proxy_ssn->connection_state.mutex, this_ethread()); + _proxy_ssn->connection_state.send_data_frames(this); this->signal_write_event(call_update); // XXX The call to signal_write_event can destroy/free the Http2Stream. // Don't modify the Http2Stream after calling this method. @@ -742,7 +742,7 @@ Http2Stream::send_response_body(bool call_update) void Http2Stream::reenable(VIO *vio) { - if (this->proxy_ssn) { + if (this->_proxy_ssn) { if (vio->op == VIO::WRITE) { SCOPED_MUTEX_LOCK(lock, this->mutex, this_ethread()); update_write_request(vio->get_reader(), INT64_MAX, true); @@ -766,8 +766,8 @@ Http2Stream::destroy() uint64_t cid = 0; // Safe to initiate SSN_CLOSE if this is the last stream - if (proxy_ssn) { - Http2ClientSession *h2_proxy_ssn = static_cast<Http2ClientSession *>(proxy_ssn); + if (_proxy_ssn) { + Http2ClientSession *h2_proxy_ssn = static_cast<Http2ClientSession *>(_proxy_ssn); SCOPED_MUTEX_LOCK(lock, h2_proxy_ssn->connection_state.mutex, this_ethread()); // Make sure the stream is removed from the stream list and priority tree // In many cases, this has been called earlier, so this call is a no-op @@ -776,7 +776,7 @@ Http2Stream::destroy() // Update session's stream counts, so it accurately goes into keep-alive state h2_proxy_ssn->connection_state.release_stream(this); - cid = proxy_ssn->connection_id(); + cid = _proxy_ssn->connection_id(); } // Clean up the write VIO in case of inactivity timeout @@ -965,7 +965,7 @@ void Http2Stream::release(IOBufferReader *r) { super::release(r); - current_reader = nullptr; // State machine is on its own way down. + _sm = nullptr; // State machine is on its own way down. this->do_io_close(); } diff --git a/proxy/http3/Http3Transaction.cc b/proxy/http3/Http3Transaction.cc index b72f33a..519ef76 100644 --- a/proxy/http3/Http3Transaction.cc +++ b/proxy/http3/Http3Transaction.cc @@ -33,14 +33,14 @@ #include "HttpSM.h" #include "HTTP2.h" -#define Http3TransDebug(fmt, ...) \ - Debug("http3_trans", "[%s] [%" PRIx32 "] " fmt, \ - static_cast<QUICConnection *>(reinterpret_cast<QUICNetVConnection *>(this->proxy_ssn->get_netvc()))->cids().data(), \ +#define Http3TransDebug(fmt, ...) \ + Debug("http3_trans", "[%s] [%" PRIx32 "] " fmt, \ + static_cast<QUICConnection *>(reinterpret_cast<QUICNetVConnection *>(this->_proxy_ssn->get_netvc()))->cids().data(), \ this->get_transaction_id(), ##__VA_ARGS__) -#define Http3TransVDebug(fmt, ...) \ - Debug("v_http3_trans", "[%s] [%" PRIx32 "] " fmt, \ - static_cast<QUICConnection *>(reinterpret_cast<QUICNetVConnection *>(this->proxy_ssn->get_netvc()))->cids().data(), \ +#define Http3TransVDebug(fmt, ...) \ + Debug("v_http3_trans", "[%s] [%" PRIx32 "] " fmt, \ + static_cast<QUICConnection *>(reinterpret_cast<QUICNetVConnection *>(this->_proxy_ssn->get_netvc()))->cids().data(), \ this->get_transaction_id(), ##__VA_ARGS__) // static void @@ -63,7 +63,7 @@ HQTransaction::HQTransaction(HQSession *session, QUICStreamIO *stream_io) : supe this->set_proxy_ssn(session); - this->sm_reader = this->_read_vio_buf.alloc_reader(); + this->_reader = this->_read_vio_buf.alloc_reader(); HTTPType http_type = HTTP_TYPE_UNKNOWN; if (this->direction() == NET_VCONNECTION_OUT) { @@ -83,24 +83,24 @@ HQTransaction::~HQTransaction() void HQTransaction::set_active_timeout(ink_hrtime timeout_in) { - if (this->proxy_ssn) { - this->proxy_ssn->set_active_timeout(timeout_in); + if (this->_proxy_ssn) { + this->_proxy_ssn->set_active_timeout(timeout_in); } } void HQTransaction::set_inactivity_timeout(ink_hrtime timeout_in) { - if (this->proxy_ssn) { - this->proxy_ssn->set_inactivity_timeout(timeout_in); + if (this->_proxy_ssn) { + this->_proxy_ssn->set_inactivity_timeout(timeout_in); } } void HQTransaction::cancel_inactivity_timeout() { - if (this->proxy_ssn) { - this->proxy_ssn->cancel_inactivity_timeout(); + if (this->_proxy_ssn) { + this->_proxy_ssn->cancel_inactivity_timeout(); } } @@ -109,7 +109,7 @@ HQTransaction::release(IOBufferReader *r) { super::release(r); this->do_io_close(); - this->current_reader = nullptr; + this->_sm = nullptr; } bool @@ -185,7 +185,7 @@ HQTransaction::do_io_close(int lerrno) this->_write_vio.op = VIO::NONE; this->_write_vio.cont = nullptr; - this->proxy_ssn->do_io_close(lerrno); + this->_proxy_ssn->do_io_close(lerrno); } void @@ -217,7 +217,7 @@ HQTransaction::reenable(VIO *vio) void HQTransaction::destroy() { - current_reader = nullptr; + _sm = nullptr; } void @@ -248,7 +248,7 @@ HQTransaction::decrement_client_transactions_stat() NetVConnectionContext_t HQTransaction::direction() const { - return this->proxy_ssn->get_netvc()->get_context(); + return this->_proxy_ssn->get_netvc()->get_context(); } /** @@ -318,7 +318,7 @@ HQTransaction::_signal_write_event() // Http3Transaction::Http3Transaction(Http3Session *session, QUICStreamIO *stream_io) : super(session, stream_io) { - static_cast<HQSession *>(this->proxy_ssn)->add_transaction(static_cast<HQTransaction *>(this)); + static_cast<HQSession *>(this->_proxy_ssn)->add_transaction(static_cast<HQTransaction *>(this)); this->_header_framer = new Http3HeaderFramer(this, &this->_write_vio, session->local_qpack(), stream_io->stream_id()); this->_data_framer = new Http3DataFramer(this, &this->_write_vio); @@ -597,7 +597,7 @@ Http3Transaction::_on_qpack_decode_complete() // Http09Transaction::Http09Transaction(Http09Session *session, QUICStreamIO *stream_io) : super(session, stream_io) { - static_cast<HQSession *>(this->proxy_ssn)->add_transaction(static_cast<HQTransaction *>(this)); + static_cast<HQSession *>(this->_proxy_ssn)->add_transaction(static_cast<HQTransaction *>(this)); SET_HANDLER(&Http09Transaction::state_stream_open); }