Skip to content

Commit 60e73e9

Browse files
shinrichzwoop
authored andcommitted
Sticky server does not work with H2 client (#7261)
(cherry picked from commit d285211)
1 parent 8dba44a commit 60e73e9

File tree

8 files changed

+18
-10
lines changed

8 files changed

+18
-10
lines changed

doc/admin-guide/files/records.config.en.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,9 @@ mptcp
977977
.. ts:cv:: CONFIG proxy.config.http.attach_server_session_to_client INT 0
978978
:overridable:
979979

980-
Control the re-use of an server session by a user agent (client) session.
980+
Control the re-use of an server session by a user agent (client) session. Currently only applies to user
981+
agents using HTTP/1.0 or HTTP/1.1. For other HTTP versions, the origin connection is always returned to the
982+
session sharing pool or closed.
981983

982984
If a user agent performs more than one HTTP transaction on its connection to |TS| a server session must be
983985
obtained for the second (and subsequent) transaction as for the first. This settings affects how that server session

proxy/ProxySession.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,10 @@ ProxySession::connection_id() const
200200
return con_id;
201201
}
202202

203-
void
203+
bool
204204
ProxySession::attach_server_session(Http1ServerSession *ssession, bool transaction_done)
205205
{
206+
return false;
206207
}
207208

208209
Http1ServerSession *

proxy/ProxySession.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class ProxySession : public VConnection, public PluginUserArgs<TS_USER_ARGS_SSN>
8989
// Virtual Methods
9090
virtual void new_connection(NetVConnection *new_vc, MIOBuffer *iobuf, IOBufferReader *reader) = 0;
9191
virtual void start() = 0;
92-
virtual void attach_server_session(Http1ServerSession *ssession, bool transaction_done = true);
92+
virtual bool attach_server_session(Http1ServerSession *ssession, bool transaction_done = true);
9393

9494
virtual void release(ProxyTransaction *trans) = 0;
9595

proxy/ProxyTransaction.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ ProxyTransaction::new_transaction(bool from_early_data)
5656
_sm->attach_client_session(this, _reader);
5757
}
5858

59-
void
59+
bool
6060
ProxyTransaction::attach_server_session(Http1ServerSession *ssession, bool transaction_done)
6161
{
62-
_proxy_ssn->attach_server_session(ssession, transaction_done);
62+
return _proxy_ssn->attach_server_session(ssession, transaction_done);
6363
}
6464

6565
void

proxy/ProxyTransaction.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class ProxyTransaction : public VConnection
3838
/// Virtual Methods
3939
//
4040
virtual void new_transaction(bool from_early_data = false);
41-
virtual void attach_server_session(Http1ServerSession *ssession, bool transaction_done = true);
41+
virtual bool attach_server_session(Http1ServerSession *ssession, bool transaction_done = true);
4242
Action *adjust_thread(Continuation *cont, int event, void *data);
4343
virtual void release(IOBufferReader *r) = 0;
4444
virtual void transaction_done();

proxy/http/Http1ClientSession.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ Http1ClientSession::new_transaction()
460460
trans.new_transaction(read_from_early_data > 0 ? true : false);
461461
}
462462

463-
void
463+
bool
464464
Http1ClientSession::attach_server_session(Http1ServerSession *ssession, bool transaction_done)
465465
{
466466
if (ssession) {
@@ -499,6 +499,7 @@ Http1ClientSession::attach_server_session(Http1ServerSession *ssession, bool tra
499499
bound_ss = nullptr;
500500
slave_ka_vio = nullptr;
501501
}
502+
return true;
502503
}
503504

504505
void

proxy/http/Http1ClientSession.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class Http1ClientSession : public ProxySession
6060
void destroy() override;
6161
void free() override;
6262

63-
void attach_server_session(Http1ServerSession *ssession, bool transaction_done = true) override;
63+
bool attach_server_session(Http1ServerSession *ssession, bool transaction_done = true) override;
6464

6565
// Implement VConnection interface.
6666
void do_io_close(int lerrno = -1) override;

proxy/http/HttpSM.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3113,10 +3113,14 @@ HttpSM::tunnel_handler_server(int event, HttpTunnelProducer *p)
31133113
// server session to so the next ka request can use it. Server sessions will
31143114
// be placed into the shared pool if the next incoming request is for a different
31153115
// origin server
3116+
bool release_origin_connection = true;
31163117
if (t_state.txn_conf->attach_server_session_to_client == 1 && ua_txn && t_state.client_info.keep_alive == HTTP_KEEPALIVE) {
31173118
Debug("http", "attaching server session to the client");
3118-
ua_txn->attach_server_session(server_session);
3119-
} else {
3119+
if (ua_txn->attach_server_session(server_session)) {
3120+
release_origin_connection = false;
3121+
}
3122+
}
3123+
if (release_origin_connection) {
31203124
// Release the session back into the shared session pool
31213125
server_session->get_netvc()->set_inactivity_timeout(HRTIME_SECONDS(t_state.txn_conf->keep_alive_no_activity_timeout_out));
31223126
server_session->release();

0 commit comments

Comments
 (0)