Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion include/proxy/http/HttpConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,12 @@ class ParsedConfigCache
std::variant<std::monostate, HostResData, HttpStatusCodeList, HttpForwarded::OptionBitSet, MgmtByte,
TargetedCacheControlHeaders>
parsed{};

ParsedValue() = default;
ParsedValue(const ParsedValue &) = delete;
ParsedValue &operator=(const ParsedValue &) = delete;
ParsedValue(ParsedValue &&) = delete;
ParsedValue &operator=(ParsedValue &&) = delete;
};

/** Return the parsed value for the configuration.
Expand All @@ -958,7 +964,7 @@ class ParsedConfigCache
static ParsedConfigCache &instance();

const ParsedValue &lookup_impl(TSOverridableConfigKey key, std::string_view value);
ParsedValue parse(TSOverridableConfigKey key, std::string_view value);
void parse_into(ParsedValue &result, TSOverridableConfigKey key, std::string_view value);

// Custom hash for the cache key.
struct CacheKeyHash {
Expand Down
11 changes: 4 additions & 7 deletions src/proxy/http/HttpConfig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -786,15 +786,14 @@ ParsedConfigCache::lookup_impl(TSOverridableConfigKey key, std::string_view valu
}

// Parse and insert.
auto [inserted_it, success] = _cache.emplace(cache_key, parse(key, value));
auto [inserted_it, success] = _cache.try_emplace(cache_key);
parse_into(inserted_it->second, key, value);
return inserted_it->second;
}

ParsedConfigCache::ParsedValue
ParsedConfigCache::parse(TSOverridableConfigKey key, std::string_view value)
void
ParsedConfigCache::parse_into(ParsedValue &result, TSOverridableConfigKey key, std::string_view value)
{
ParsedValue result{};

// Store the string value - the parsed structures may reference this.
result.conf_value_storage = std::string(value);

Expand Down Expand Up @@ -843,8 +842,6 @@ ParsedConfigCache::parse(TSOverridableConfigKey key, std::string_view value)
// No special parsing needed for this config.
break;
}

return result;
}

/** Template for creating conversions and initialization for @c std::chrono based configuration variables.
Expand Down