From a7db375f5d9b642a807002e0a0fce16ac9fdc348 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Sat, 11 Jan 2025 20:23:41 +0000 Subject: [PATCH] accounting: fix race stopping/starting the stats counter This was picked up by the race detector in the CI. --- fs/accounting/stats.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/accounting/stats.go b/fs/accounting/stats.go index e46f95e5c..221ab3001 100644 --- a/fs/accounting/stats.go +++ b/fs/accounting/stats.go @@ -360,8 +360,8 @@ func (s *StatsInfo) averageLoop() { // Start the average loop func (s *StatsInfo) startAverageLoop() { - s.mu.RLock() - defer s.mu.RUnlock() + s.mu.Lock() + defer s.mu.Unlock() s.average.startOnce.Do(func() { s.average.stopped.Add(1) go s.averageLoop() @@ -380,8 +380,8 @@ func (s *StatsInfo) _stopAverageLoop() { // Stop the average loop func (s *StatsInfo) stopAverageLoop() { - s.mu.RLock() - defer s.mu.RUnlock() + s.mu.Lock() + defer s.mu.Unlock() s._stopAverageLoop() }