Skip to content

Commit a75d036

Browse files
committed
Add extra state for allow_half_open setting
1 parent 89cf5af commit a75d036

File tree

69 files changed

+117
-89
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+117
-89
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4198,12 +4198,16 @@ Sockets
41984198
exception being if you run |TS| with a protocol plugin, and would
41994199
like for it to not support HTTP requests at all.
42004200

4201-
.. ts:cv:: CONFIG proxy.config.http.allow_half_open INT 1
4201+
.. ts:cv:: CONFIG proxy.config.http.allow_half_open INT 0
42024202
:reloadable:
42034203
:overridable:
42044204

4205-
Turn on or off support for connection half open for client side. Default is on, so
4206-
after client sends FIN, the connection is still there.
4205+
Controls whether ATS will continue to send data over a connection when the client side
4206+
closes (operating in a half open state). The client would have to be be written to
4207+
expect this to process the extra data. A value of 0 disables the half open connection from
4208+
consideration. A value of 1 cause |TS| to send data after receiving a FIN on non TLS connections.
4209+
A value of 2 will cause |TS| to also send data over TLS connections after the client sends a
4210+
FIN.
42074211

42084212
.. ts:cv:: CONFIG proxy.config.http.wait_for_cache INT 0
42094213

mgmt/RecordsConfig.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ static const RecordElement RecordsConfig[] =
303303
// # basics #
304304
// ##########
305305
// #
306-
{RECT_CONFIG, "proxy.config.http.allow_half_open", RECD_INT, "1", RECU_DYNAMIC, RR_NULL, RECC_INT, "[0-1]", RECA_NULL}
306+
{RECT_CONFIG, "proxy.config.http.allow_half_open", RECD_INT, "0", RECU_DYNAMIC, RR_NULL, RECC_INT, "[0-2]", RECA_NULL}
307307
,
308308
{RECT_CONFIG, "proxy.config.http.enabled", RECD_INT, "1", RECU_RESTART_TM, RR_NULL, RECC_INT, "[0-1]", RECA_NULL}
309309
,

plugins/experimental/slice/intercept.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ intercept_hook(TSCont contp, TSEvent event, void *edata)
5757
if (data->m_dnstream.m_read.isOpen() && edata == data->m_dnstream.m_read.m_vio) {
5858
if (handle_client_req(contp, event, data)) {
5959
// DEBUG_LOG("shutting down read from client pipe");
60-
TSVConnShutdown(data->m_dnstream.m_vc, 1, 0);
60+
// TSVConnShutdown(data->m_dnstream.m_vc, 1, 0);
6161
}
6262
}
6363
// server wants more data from us, should never happen
6464
// every time TSHttpConnect is called this resets
6565
else if (data->m_upstream.m_write.isOpen() && edata == data->m_upstream.m_write.m_vio) {
6666
// DEBUG_LOG("shutting down send to server pipe");
67-
TSVConnShutdown(data->m_upstream.m_vc, 0, 1);
67+
// TSVConnShutdown(data->m_upstream.m_vc, 0, 1);
6868
}
6969
// server has data for us, typically handle just the header
7070
else if (data->m_upstream.m_read.isOpen() && edata == data->m_upstream.m_read.m_vio) {

proxy/http/Http1ClientSession.cc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -523,10 +523,14 @@ Http1ClientSession::start()
523523
}
524524

525525
bool
526-
Http1ClientSession::allow_half_open() const
526+
Http1ClientSession::allow_half_open(bool allow_half_open_tls) const
527527
{
528-
// Only allow half open connections if the not over TLS
529-
return (client_vc && dynamic_cast<SSLNetVConnection *>(client_vc) == nullptr);
528+
if (allow_half_open_tls) {
529+
return true;
530+
} else {
531+
// Only allow half open connections if the not over TLS
532+
return (client_vc && dynamic_cast<SSLNetVConnection *>(client_vc) == nullptr);
533+
}
530534
}
531535

532536
void

proxy/http/Http1ClientSession.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class Http1ClientSession : public ProxySession
7272
void reenable(VIO *vio) override;
7373

7474
// Accessor Methods
75-
bool allow_half_open() const;
75+
bool allow_half_open(bool half_open_tls) const;
7676
void set_half_close_flag(bool flag) override;
7777
bool get_half_close_flag() const override;
7878
bool is_chunked_encoding_supported() const override;

proxy/http/Http1Transaction.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,11 @@ Http1Transaction::reenable(VIO *vio)
6868
bool
6969
Http1Transaction::allow_half_open() const
7070
{
71-
bool config_allows_it = (_sm) ? _sm->t_state.txn_conf->allow_half_open > 0 : true;
71+
bool config_allows_it = (_sm) ? _sm->t_state.txn_conf->allow_half_open > 0 : false;
72+
bool config_allows_tls_half_open = (_sm) ? _sm->t_state.txn_conf->allow_half_open > 1 : false;
7273
if (config_allows_it) {
7374
// Check with the session to make sure the underlying transport allows the half open scenario
74-
return static_cast<Http1ClientSession *>(_proxy_ssn)->allow_half_open();
75+
return static_cast<Http1ClientSession *>(_proxy_ssn)->allow_half_open(config_allows_tls_half_open);
7576
}
7677
return false;
7778
}

proxy/http/HttpSM.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3296,8 +3296,8 @@ HttpSM::tunnel_handler_ua(int event, HttpTunnelConsumer *c)
32963296
// only external POSTs should be subject to this logic; ruling out internal POSTs here
32973297
bool is_eligible_post_request = ((t_state.method == HTTP_WKSIDX_POST) && !is_internal);
32983298

3299-
if ((is_eligible_post_request || t_state.client_info.pipeline_possible == true) && c->producer->vc_type != HT_STATIC &&
3300-
event == VC_EVENT_WRITE_COMPLETE) {
3299+
if ((is_eligible_post_request || t_state.client_info.pipeline_possible == true) && ua_txn->allow_half_open() &&
3300+
c->producer->vc_type != HT_STATIC && event == VC_EVENT_WRITE_COMPLETE) {
33013301
ua_txn->set_half_close_flag(true);
33023302
}
33033303

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
GET HTTP://www.customplugin204.test/ HTTP/1.1
2+
Connection:close
23

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
GET HTTP://www.customtemplate204.test/ HTTP/1.1
2+
Connection:close
23

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
GET HTTP://www.default204.test/ HTTP/1.1
2+
Connection:close
23

0 commit comments

Comments
 (0)