accounting: Fix stats (speed=0 and eta=nil) when starting jobs via rc
Before this change we used the current context to start the average loop. This means that if the context came from the rc the average loop would be cancelled at the end of the rc request leading the speed not being measured. This uses the background context for the accounting loop so it doesn't get cancelled when its parent gets cancelled.
This commit is contained in:
@@ -368,7 +368,7 @@ func (s *StatsInfo) averageLoop(ctx context.Context) {
|
||||
// Call with the mutex held
|
||||
func (s *StatsInfo) _startAverageLoop() {
|
||||
if !s.average.started {
|
||||
ctx, cancel := context.WithCancel(s.ctx)
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
s.average.cancel = cancel
|
||||
s.average.started = true
|
||||
s.average.stopped.Add(1)
|
||||
|
||||
Reference in New Issue
Block a user