From cd6784021f39d09ab6b29261e43aea5fd96cc00c Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Sun, 6 Aug 2023 00:50:05 +0100 Subject: Make config file cache invalidation more useful. --- src/configreader.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/configreader.cpp') diff --git a/src/configreader.cpp b/src/configreader.cpp index 9f6c80f67..47dd87fc6 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -92,13 +92,13 @@ ServerConfig::ServerConfig() { } -ServerConfig::ReadResult ServerConfig::ReadFile(const std::string& file, bool invalidate) +ServerConfig::ReadResult ServerConfig::ReadFile(const std::string& file, time_t mincache) { auto contents = filecontents.find(file); if (contents != filecontents.end()) { - if (!invalidate) - return ReadResult(contents->second, {}); + if (!mincache || contents->second.second >= mincache) + return ReadResult(contents->second.first, {}); filecontents.erase(contents); } @@ -129,8 +129,8 @@ ServerConfig::ReadResult ServerConfig::ReadFile(const std::string& file, bool in datastream.write(databuf, len); } - filecontents[name] = datastream.str(); - return ReadResult(filecontents[name], {}); + filecontents[name] = { datastream.str(), ServerInstance->Time() }; + return ReadResult(filecontents[name].first, {}); } void ServerConfig::CrossCheckOperBlocks() -- cgit v1.3.1-10-gc9f91