From f837bb55c44d426b694bc8876b0584a3c57ced09 Mon Sep 17 00:00:00 2001 From: Icaro Motta Date: Wed, 14 Aug 2024 12:45:55 -0300 Subject: [PATCH] fix(wallet)_: pass loop var by value to goroutine (#5710) --- services/wallet/async/scheduler.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/wallet/async/scheduler.go b/services/wallet/async/scheduler.go index d8cfc6217..c20c24d69 100644 --- a/services/wallet/async/scheduler.go +++ b/services/wallet/async/scheduler.go @@ -193,9 +193,9 @@ func (s *Scheduler) Stop() { for pair := s.queue.Oldest(); pair != nil; pair = pair.Next() { // Notify the queued one that they are canceled if pair.Value.policy == ReplacementPolicyCancelOld { - go func() { - pair.Value.resFn(nil, pair.Value.taskType, context.Canceled) - }() + go func(val *taskContext) { + val.resFn(nil, val.taskType, context.Canceled) + }(pair.Value) } s.queue.Delete(pair.Value.taskType) }