diff --git a/doc/admin-guide/files/records.config.en.rst b/doc/admin-guide/files/records.config.en.rst index 395a5ad218a..7e4a97e5bce 100644 --- a/doc/admin-guide/files/records.config.en.rst +++ b/doc/admin-guide/files/records.config.en.rst @@ -999,7 +999,9 @@ mptcp .. ts:cv:: CONFIG proxy.config.http.attach_server_session_to_client INT 0 :overridable: - Control the re-use of an server session by a user agent (client) session. + Control the re-use of an server session by a user agent (client) session. Currently only applies to user + agents using HTTP/1.0 or HTTP/1.1. For other HTTP versions, the origin connection is always returned to the + session sharing pool or closed. If a user agent performs more than one HTTP transaction on its connection to |TS| a server session must be obtained for the second (and subsequent) transaction as for the first. This settings affects how that server session diff --git a/proxy/ProxySession.cc b/proxy/ProxySession.cc index 3d9c2039fc4..07af66a9f46 100644 --- a/proxy/ProxySession.cc +++ b/proxy/ProxySession.cc @@ -200,9 +200,10 @@ ProxySession::connection_id() const return con_id; } -void +bool ProxySession::attach_server_session(Http1ServerSession *ssession, bool transaction_done) { + return false; } Http1ServerSession * diff --git a/proxy/ProxySession.h b/proxy/ProxySession.h index f306ffc7ca5..8c6a0712e28 100644 --- a/proxy/ProxySession.h +++ b/proxy/ProxySession.h @@ -89,7 +89,7 @@ class ProxySession : public VConnection, public PluginUserArgs // Virtual Methods virtual void new_connection(NetVConnection *new_vc, MIOBuffer *iobuf, IOBufferReader *reader) = 0; virtual void start() = 0; - virtual void attach_server_session(Http1ServerSession *ssession, bool transaction_done = true); + virtual bool attach_server_session(Http1ServerSession *ssession, bool transaction_done = true); virtual void release(ProxyTransaction *trans) = 0; diff --git a/proxy/ProxyTransaction.cc b/proxy/ProxyTransaction.cc index 214c710c5ec..56c40b261fa 100644 --- a/proxy/ProxyTransaction.cc +++ b/proxy/ProxyTransaction.cc @@ -56,10 +56,10 @@ ProxyTransaction::new_transaction(bool from_early_data) _sm->attach_client_session(this, _reader); } -void +bool ProxyTransaction::attach_server_session(Http1ServerSession *ssession, bool transaction_done) { - _proxy_ssn->attach_server_session(ssession, transaction_done); + return _proxy_ssn->attach_server_session(ssession, transaction_done); } void diff --git a/proxy/ProxyTransaction.h b/proxy/ProxyTransaction.h index 5ae71c84656..9cd4af85c23 100644 --- a/proxy/ProxyTransaction.h +++ b/proxy/ProxyTransaction.h @@ -38,7 +38,7 @@ class ProxyTransaction : public VConnection /// Virtual Methods // virtual void new_transaction(bool from_early_data = false); - virtual void attach_server_session(Http1ServerSession *ssession, bool transaction_done = true); + virtual bool attach_server_session(Http1ServerSession *ssession, bool transaction_done = true); Action *adjust_thread(Continuation *cont, int event, void *data); virtual void release(IOBufferReader *r) = 0; virtual void transaction_done(); diff --git a/proxy/http/Http1ClientSession.cc b/proxy/http/Http1ClientSession.cc index 7d68b248bf9..4ffc6b1abc7 100644 --- a/proxy/http/Http1ClientSession.cc +++ b/proxy/http/Http1ClientSession.cc @@ -460,7 +460,7 @@ Http1ClientSession::new_transaction() trans.new_transaction(read_from_early_data > 0 ? true : false); } -void +bool Http1ClientSession::attach_server_session(Http1ServerSession *ssession, bool transaction_done) { if (ssession) { @@ -499,6 +499,7 @@ Http1ClientSession::attach_server_session(Http1ServerSession *ssession, bool tra bound_ss = nullptr; slave_ka_vio = nullptr; } + return true; } void diff --git a/proxy/http/Http1ClientSession.h b/proxy/http/Http1ClientSession.h index aef989de0ca..686f5f4b2dc 100644 --- a/proxy/http/Http1ClientSession.h +++ b/proxy/http/Http1ClientSession.h @@ -60,7 +60,7 @@ class Http1ClientSession : public ProxySession void destroy() override; void free() override; - void attach_server_session(Http1ServerSession *ssession, bool transaction_done = true) override; + bool attach_server_session(Http1ServerSession *ssession, bool transaction_done = true) override; // Implement VConnection interface. void do_io_close(int lerrno = -1) override; diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc index 1065970d680..1c4e663cf64 100644 --- a/proxy/http/HttpSM.cc +++ b/proxy/http/HttpSM.cc @@ -3143,10 +3143,14 @@ HttpSM::tunnel_handler_server(int event, HttpTunnelProducer *p) // server session to so the next ka request can use it. Server sessions will // be placed into the shared pool if the next incoming request is for a different // origin server + bool release_origin_connection = true; if (t_state.txn_conf->attach_server_session_to_client == 1 && ua_txn && t_state.client_info.keep_alive == HTTP_KEEPALIVE) { Debug("http", "attaching server session to the client"); - ua_txn->attach_server_session(server_session); - } else { + if (ua_txn->attach_server_session(server_session)) { + release_origin_connection = false; + } + } + if (release_origin_connection) { // Release the session back into the shared session pool server_session->get_netvc()->set_inactivity_timeout(HRTIME_SECONDS(t_state.txn_conf->keep_alive_no_activity_timeout_out)); server_session->release();