]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix max-stale in default refresh_pattern (#1664)
authorAlex Rousskov <rousskov@measurement-factory.com>
Thu, 8 Feb 2024 22:03:44 +0000 (22:03 +0000)
committerAmos Jeffries <yadij@users.noreply.github.com>
Mon, 12 Feb 2024 08:23:23 +0000 (21:23 +1300)
RefreshPattern constructor must set data fields to honor refresh_pattern
defaults promised in squid.conf.documented. For max-stale, that implies
making max_stale negative. A negative value allows refreshCheck() to use
a max_stale directive value (i.e. Config.maxStale that defaults to 1
week). The buggy constructor set max_stale to 0 instead and, hence,
refreshCheck() ignored max_stale directive when no refresh_pattern rules
were configured.

The fixed bug did not affect Squids configured using explicit
refresh_pattern rules because those rules are handled by
parse_refreshpattern() which sets max_stale to -1 by default. Our
squid.conf.default does have explicit refresh_pattern rules.

src/RefreshPattern.h

index 46561dc9af2d0fb3ad71058162f5e919bb638138..85b8a8500fee4e0f13b5e2fbabb33c9ef8263865 100644 (file)
@@ -35,7 +35,7 @@ public:
     explicit RefreshPattern(RegexPointer aRegex):
         min(0), pct(0.20), max(REFRESH_DEFAULT_MAX),
         next(nullptr),
-        max_stale(0),
+        max_stale(-1),
         regex_(std::move(aRegex))
     {
         memset(&flags, 0, sizeof(flags));