accounting: fix race detected by the race detector

This commit is contained in:
Nick Craig-Wood 2024-06-18 12:12:26 +01:00
parent d08b49d723
commit 10270a4354

View File

@ -313,7 +313,9 @@ func (s *StatsInfo) calculateTransferStats() (ts transferStats) {
// note that s.bytes already includes transferringBytesDone so // note that s.bytes already includes transferringBytesDone so
// we take it off here to avoid double counting // we take it off here to avoid double counting
ts.totalBytes = s.transferQueueSize + s.bytes + transferringBytesTotal - transferringBytesDone ts.totalBytes = s.transferQueueSize + s.bytes + transferringBytesTotal - transferringBytesDone
s.average.mu.Lock()
ts.speed = s.average.speed ts.speed = s.average.speed
s.average.mu.Unlock()
dt := s._totalDuration() dt := s._totalDuration()
ts.transferTime = dt.Seconds() ts.transferTime = dt.Seconds()