bneradt commented on PR #12768:
URL: https://github.com/apache/trafficserver/pull/12768#issuecomment-3697741030
This seems to resolve the "not in certificate" issue when I put the
following patch down on a box in addition to the one in this PR, and I don't
see the cache inconsistency issues:
```diff
diff --git a/include/proxy/hdrs/HTTP.h b/include/proxy/hdrs/HTTP.h
index c7c0f65a61..297f8c67d4 100644
--- a/include/proxy/hdrs/HTTP.h
+++ b/include/proxy/hdrs/HTTP.h
@@ -447,17 +447,15 @@ class IOBufferReader;
class HTTPHdr : public MIMEHdr
{
public:
- HTTPHdrImpl *m_http = nullptr;
- mutable URL m_url_cached;
- mutable MIMEField *m_host_mime = nullptr;
- mutable const char *m_host_ptr = nullptr; ///< Cached host
value pointer for staleness detection.
- mutable int m_host_value_len = 0; ///< Cached raw
Host header value length for staleness detection.
- mutable int m_host_length = 0; ///< Length of
hostname (parsed, excludes port).
- mutable int m_port = 0; ///< Target port.
- mutable bool m_target_cached = false; ///< Whether host
name and port are cached.
- mutable bool m_target_in_url = false; ///< Whether host
name and port are in the URL.
- mutable bool m_100_continue_sent = false; ///< Whether ATS
sent a 100 Continue optimized response.
- mutable bool m_100_continue_required = false; ///< Whether
100_continue is in the Expect header.
+ HTTPHdrImpl *m_http = nullptr;
+ mutable URL m_url_cached;
+ mutable MIMEField *m_host_mime = nullptr;
+ mutable int m_host_length = 0; ///< Length of
hostname.
+ mutable int m_port = 0; ///< Target port.
+ mutable bool m_target_cached = false; ///< Whether host
name and port are cached.
+ mutable bool m_target_in_url = false; ///< Whether host
name and port are in the URL.
+ mutable bool m_100_continue_sent = false; ///< Whether ATS sent
a 100 Continue optimized response.
+ mutable bool m_100_continue_required = false; ///< Whether
100_continue is in the Expect header.
/// Set if the port was effectively specified in the header.
/// @c true if the target (in the URL or the HOST field) also specified
/// a port. That is, @c true if whatever source had the target host
@@ -734,12 +732,33 @@ HTTPHdr::print(char *buf, int bufsize, int *bufindex,
int *dumpoffset) const
inline void
HTTPHdr::_test_and_fill_target_cache() const
{
- // Check if cache is stale: either not cached, or the Host header value
has changed.
- // We check both pointer and length to detect modifications even in the
unlikely case
- // where heap compaction causes a new allocation at the same address.
- if (!m_target_cached ||
- (m_host_mime && (m_host_mime->m_ptr_value != m_host_ptr ||
m_host_mime->m_len_value != m_host_value_len))) {
+ if (!m_target_cached) {
this->_fill_target_cache();
+ return;
+ }
+
+ // If host came from the Host header (not URL), check for staleness by
verifying
+ // the current Host header value length matches what we expect from
cached values.
+ if (!m_target_in_url && m_host_mime != nullptr) {
+ int expected_len = m_host_length;
+ if (m_port_in_header && m_port > 0) {
+ // Account for ":port" suffix in the raw Host header value.
+ expected_len += 1; // colon
+ if (m_port < 10) {
+ expected_len += 1;
+ } else if (m_port < 100) {
+ expected_len += 2;
+ } else if (m_port < 1000) {
+ expected_len += 3;
+ } else if (m_port < 10000) {
+ expected_len += 4;
+ } else {
+ expected_len += 5;
+ }
+ }
+ if (m_host_mime->m_len_value != expected_len) {
+ this->_fill_target_cache();
+ }
}
}
diff --git a/src/proxy/hdrs/HTTP.cc b/src/proxy/hdrs/HTTP.cc
index 079c7cc250..f0db0665e7 100644
--- a/src/proxy/hdrs/HTTP.cc
+++ b/src/proxy/hdrs/HTTP.cc
@@ -1640,8 +1640,6 @@ HTTPHdr::_fill_target_cache() const
m_target_in_url = false;
m_port_in_header = false;
m_host_mime = nullptr;
- m_host_ptr = nullptr;
- m_host_value_len = 0;
// Check in the URL first, then the HOST field.
std::string_view host;
if (host = url->host_get(); nullptr != host.data()) {
@@ -1656,10 +1654,7 @@ HTTPHdr::_fill_target_cache() const
m_host_length = static_cast<int>(host.length());
if (m_host_mime != nullptr) {
- // Cache pointer and length for staleness detection - if either
changes, the value was modified.
- m_host_ptr = m_host_mime->m_ptr_value;
- m_host_value_len = m_host_mime->m_len_value;
- m_port = 0;
+ m_port = 0;
if (!port.empty()) {
for (auto c : port) {
if (isdigit(c)) {
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]