URI: 
       cache/dynacache: Prevent multiple concurrent resizes - hugo - [fork] hugo port for 9front
  HTML git clone git@git.drkhsh.at/hugo.git
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
   DIR README
   DIR LICENSE
       ---
   DIR commit 564bae06f6513cbca80bd54411f9a66ec2115995
   DIR parent bf14d0cb26df901cccea593dfefaabfdc42d01af
  HTML Author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
       Date:   Fri, 23 Feb 2024 17:23:37 +0100
       
       cache/dynacache: Prevent multiple concurrent resizes
       
       Updates #12129
       
       Diffstat:
         M cache/dynacache/dynacache.go        |       9 ++++++++-
       
       1 file changed, 8 insertions(+), 1 deletion(-)
       ---
   DIR diff --git a/cache/dynacache/dynacache.go b/cache/dynacache/dynacache.go
       @@ -119,7 +119,8 @@ func (o OptionsPartition) CalculateMaxSize(maxSizePerPartition int) int {
        
        // A dynamic partitioned cache.
        type Cache struct {
       -        mu sync.RWMutex
       +        mu       sync.RWMutex
       +        resizeMu sync.Mutex
        
                partitions map[string]PartitionManager
        
       @@ -231,6 +232,12 @@ func (c *Cache) Stop() {
        }
        
        func (c *Cache) adjustCurrentMaxSize() {
       +        if !c.resizeMu.TryLock() {
       +                // Prevent multiple concurrent resizes.
       +                return
       +        }
       +        defer c.resizeMu.Unlock()
       +
                c.mu.RLock()
                defer c.mu.RUnlock()