1
0
mirror of https://github.com/rclone/rclone.git synced 2026-02-25 17:03:21 +00:00

accounting: fix race stopping/starting the stats counter

This was picked up by the race detector in the CI.
This commit is contained in:
Nick Craig-Wood
2025-01-11 20:23:41 +00:00
parent 101dcfe157
commit a7db375f5d

View File

@@ -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()
}