mirror of
https://github.com/rclone/rclone.git
synced 2025-01-22 16:33:18 +08:00
accounting: fix race stopping/starting the stats counter
Some checks are pending
Docker beta build / Build image job (push) Waiting to run
Some checks are pending
Docker beta build / Build image job (push) Waiting to run
This was picked up by the race detector in the CI.
This commit is contained in:
parent
101dcfe157
commit
a7db375f5d
|
@ -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()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user