You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by sh...@apache.org on 2021/07/29 13:56:33 UTC
[trafficserver] branch master updated: Abstract adding Connection:
close header to avoid triggering H2 draining logic (#8178)
This is an automated email from the ASF dual-hosted git repository.
shinrich pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new 658e3cd Abstract adding Connection: close header to avoid triggering H2 draining logic (#8178)
658e3cd is described below
commit 658e3cde33a74353ec520fa18ead7035821485f1
Author: Susan Hinrichs <sh...@verizonmedia.com>
AuthorDate: Thu Jul 29 08:56:24 2021 -0500
Abstract adding Connection: close header to avoid triggering H2 draining logic (#8178)
---
proxy/ProxyTransaction.cc | 8 ++++++++
proxy/ProxyTransaction.h | 4 ++++
proxy/http/Http1Transaction.h | 7 +++++++
proxy/http/HttpSM.cc | 2 +-
proxy/http/HttpTransact.cc | 11 +++++++++--
5 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/proxy/ProxyTransaction.cc b/proxy/ProxyTransaction.cc
index 3f1ace9..cb80b3c 100644
--- a/proxy/ProxyTransaction.cc
+++ b/proxy/ProxyTransaction.cc
@@ -240,3 +240,11 @@ ProxyTransaction::allow_half_open() const
{
return false;
}
+
+// Most protocols will not want to set the Connection: header
+// For H2 it will initiate the drain logic. So we make do nothing
+// the default action.
+void
+ProxyTransaction::set_close_connection(HTTPHdr &hdr) const
+{
+}
diff --git a/proxy/ProxyTransaction.h b/proxy/ProxyTransaction.h
index 82a07d6..261af68 100644
--- a/proxy/ProxyTransaction.h
+++ b/proxy/ProxyTransaction.h
@@ -87,6 +87,10 @@ public:
// Returns true if there is a request body for this request
virtual bool has_request_body(int64_t content_length, bool is_chunked_set) const;
+ // Worker function to set Connection:close header if appropriate for
+ // underlying protocol
+ virtual void set_close_connection(HTTPHdr &hdr) const;
+
sockaddr const *get_remote_addr() const;
virtual HTTPVersion get_version(HTTPHdr &hdr) const;
diff --git a/proxy/http/Http1Transaction.h b/proxy/http/Http1Transaction.h
index be0a174..aeb1d3a 100644
--- a/proxy/http/Http1Transaction.h
+++ b/proxy/http/Http1Transaction.h
@@ -43,6 +43,7 @@ public:
// Methods
int get_transaction_id() const override;
void set_reader(IOBufferReader *reader);
+ void set_close_connection(HTTPHdr &hdr) const override;
////////////////////
// Variables
@@ -71,3 +72,9 @@ Http1Transaction::set_reader(IOBufferReader *reader)
{
_reader = reader;
}
+
+inline void
+Http1Transaction::set_close_connection(HTTPHdr &hdr) const
+{
+ hdr.value_set(MIME_FIELD_CONNECTION, MIME_LEN_CONNECTION, "close", 5);
+}
diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc
index 67d18b8..4f6e06d 100644
--- a/proxy/http/HttpSM.cc
+++ b/proxy/http/HttpSM.cc
@@ -5873,7 +5873,7 @@ HttpSM::do_drain_request_body(HTTPHdr &response)
close_connection:
t_state.client_info.keep_alive = HTTP_NO_KEEPALIVE;
- response.value_set(MIME_FIELD_CONNECTION, MIME_LEN_CONNECTION, "close", 5);
+ ua_txn->set_close_connection(response);
}
void
diff --git a/proxy/http/HttpTransact.cc b/proxy/http/HttpTransact.cc
index 6e66aa4..ce2d7fa 100644
--- a/proxy/http/HttpTransact.cc
+++ b/proxy/http/HttpTransact.cc
@@ -6891,7 +6891,10 @@ HttpTransact::handle_request_keep_alive_headers(State *s, HTTPVersion ver, HTTPH
if (s->current.request_to == PARENT_PROXY && parent_is_proxy(s)) {
heads->value_set(MIME_FIELD_PROXY_CONNECTION, MIME_LEN_PROXY_CONNECTION, "close", 5);
} else {
- heads->value_set(MIME_FIELD_CONNECTION, MIME_LEN_CONNECTION, "close", 5);
+ ProxyTransaction *svr = s->state_machine->get_server_txn();
+ if (svr) {
+ svr->set_close_connection(*heads);
+ }
}
}
// Note: if we are 1.1, we always need to send the close
@@ -7050,7 +7053,11 @@ HttpTransact::handle_response_keep_alive_headers(State *s, HTTPVersion ver, HTTP
case KA_CLOSE:
case KA_DISABLED:
if (s->client_info.keep_alive != HTTP_NO_KEEPALIVE || (ver == HTTP_1_1)) {
- heads->value_set(c_hdr_field_str, c_hdr_field_len, "close", 5);
+ if (s->client_info.proxy_connect_hdr) {
+ heads->value_set(c_hdr_field_str, c_hdr_field_len, "close", 5);
+ } else if (s->state_machine->ua_txn != nullptr) {
+ s->state_machine->ua_txn->set_close_connection(*heads);
+ }
s->client_info.keep_alive = HTTP_NO_KEEPALIVE;
}
// Note: if we are 1.1, we always need to send the close