bneradt commented on code in PR #13516:
URL: https://github.com/apache/trafficserver/pull/13516#discussion_r3908394551
##########
src/api/InkAPI.cc:
##########
@@ -7521,6 +7521,14 @@ TSHttpTxnConfigStringSet(TSHttpTxn txnp,
TSOverridableConfigKey conf, const char
s->t_state.setup_per_txn_configs();
+ auto set_cached_string = [conf, value, length](char *&destination, size_t
&destination_length) {
+ if (value && length > 0) {
+ auto &parsed = ParsedConfigCache::lookup(conf,
std::string_view(value, length));
+ destination = const_cast<char
*>(parsed.conf_value_storage.data());
+ destination_length = length;
+ }
+ };
Review Comment:
Fixed in `6758d6cce1`. The eight direct SSL string overrides now copy into
the transaction arena, which preserves explicit lengths and a trailing NUL for
the transaction lifetime without retaining unique per-transaction values in the
process-wide parsed-config cache. The focused test also verifies clearing these
values.
##########
src/api/unit_tests/test_HttpOverridableConfig.cc:
##########
@@ -0,0 +1,209 @@
+/** @file
+
+ Catch based unit tests for HTTP overridable configuration APIs.
+
+ @section license License
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ */
+
+#include "iocore/eventsystem/ConfigProcessor.h"
+#include "iocore/net/ConnectionTracker.h"
+#include "proxy/http/HttpConfig.h"
+#include "proxy/http/HttpSM.h"
+#include "proxy/http/OverridableConfigDefs.h"
+#include "ts/ts.h"
+
+#include <catch2/catch_test_macros.hpp>
+
+#include <array>
+#include <string>
+#include <string_view>
+
+namespace
+{
+struct ConfigDescriptor {
+ std::string_view name;
+ TSOverridableConfigKey key;
+ TSRecordDataType type;
+};
+
+// clang-format off
+static constexpr std::array<ConfigDescriptor, TS_CONFIG_LAST_ENTRY>
CONFIG_DESCRIPTORS{{
+#define X_CONFIG_DESCRIPTOR(CONFIG_KEY, MEMBER, RECORD_NAME, DATA_TYPE, CONV) \
+ {RECORD_NAME, TS_CONFIG_##CONFIG_KEY, TS_RECORDDATATYPE_##DATA_TYPE},
+ OVERRIDABLE_CONFIGS(X_CONFIG_DESCRIPTOR)
+#undef X_CONFIG_DESCRIPTOR
+}};
+// clang-format on
+
+class TestHttpTxn
+{
+public:
+ TestHttpTxn()
+ {
+ if (HttpConfig::m_id == 0) {
+ HttpConfig::m_id = configProcessor.set(HttpConfig::m_id, new
HttpConfigParams);
+ }
+
+ _sm.magic = HttpSmMagic_t::ALIVE;
+ _sm.t_state.http_config_param = HttpConfig::acquire();
+ REQUIRE(_sm.t_state.http_config_param != nullptr);
+ _sm.t_state.txn_conf = &_sm.t_state.http_config_param->oride;
+ }
+
+ operator TSHttpTxn() { return reinterpret_cast<TSHttpTxn>(&_sm); }
+
+ const HttpForwarded::OptionBitSet &
+ forwarded_options() const
+ {
+ return _sm.t_state.txn_conf->insert_forwarded;
+ }
+
+private:
+ HttpSM _sm;
+};
+} // namespace
+
+TEST_CASE("Find HTTP overridable configurations", "[api][overridable-config]")
+{
+ for (auto const &descriptor : CONFIG_DESCRIPTORS) {
+ TSOverridableConfigKey key;
+ TSRecordDataType type;
+
+ INFO(descriptor.name);
+
+ REQUIRE(TSHttpTxnConfigFind(descriptor.name.data(), -1, &key, &type) ==
TS_SUCCESS);
+ CHECK(key == descriptor.key);
+ CHECK(type == descriptor.type);
+
+ REQUIRE(TSHttpTxnConfigFind(descriptor.name.data(),
descriptor.name.size(), &key, &type) == TS_SUCCESS);
Review Comment:
Fixed in `6758d6cce1` by explicitly casting `descriptor.name.size()` to the
`int` length accepted by `TSHttpTxnConfigFind()`. Full
configure/format/build/install and the focused overridable-config suite (1538
assertions) pass in `asfats5`.
--
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]