Skip to content

Commit b8ad187

Browse files
committed
Add extra state for allow_half_open_setting
1 parent 2d0233f commit b8ad187

File tree

6 files changed

+27
-11
lines changed

6 files changed

+27
-11
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4202,8 +4202,12 @@ Sockets
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, "1", 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
,

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: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3250,6 +3250,9 @@ HttpSM::tunnel_handler_ua(int event, HttpTunnelConsumer *c)
32503250
close_connection = false;
32513251
}
32523252
}
3253+
// Transaction is done. Clear the half open flag so the client
3254+
// connection can close the next time it is asked
3255+
ua_txn->set_half_close_flag(false);
32533256
break;
32543257
case VC_EVENT_WRITE_READY:
32553258
case VC_EVENT_READ_READY:
@@ -3292,12 +3295,16 @@ HttpSM::tunnel_handler_ua(int event, HttpTunnelConsumer *c)
32923295
if (close_connection) {
32933296
// If the client could be pipelining or is doing a POST, we need to
32943297
// set the ua_txn into half close mode
3298+
// For POST, this needs to be done in case the POST resulted in an error.
3299+
// Must set the half_open here so the POST clean up occurs as described
3300+
// in TS-3778. I would think in a success case, the half_open flag is unneeded
3301+
// since the transaction has completed.
32953302

32963303
// only external POSTs should be subject to this logic; ruling out internal POSTs here
32973304
bool is_eligible_post_request = ((t_state.method == HTTP_WKSIDX_POST) && !is_internal);
32983305

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) {
3306+
if ((is_eligible_post_request || t_state.client_info.pipeline_possible == true) && ua_txn->allow_half_open() &&
3307+
c->producer->vc_type != HT_STATIC && event == VC_EVENT_WRITE_COMPLETE) {
33013308
ua_txn->set_half_close_flag(true);
33023309
}
33033310

0 commit comments

Comments
 (0)