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:
Nick Craig-Wood
2025-08-16 16:33:38 +01:00
parent 16ad0c2aef
commit 4b777db20b
+1 -1
View File
@@ -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)