From ff442e9559d440602a0efd4527a7247ca2d1a0f9 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Fri, 19 Feb 2021 11:14:51 +0300 Subject: [PATCH] [#378] shard/gc: Avoid usage of the range-loop vars in go-routines Signed-off-by: Leonard Lyubich --- pkg/local_object_storage/shard/gc.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/local_object_storage/shard/gc.go b/pkg/local_object_storage/shard/gc.go index fc39a9b0..8363ebf9 100644 --- a/pkg/local_object_storage/shard/gc.go +++ b/pkg/local_object_storage/shard/gc.go @@ -123,7 +123,9 @@ func (gc *gc) listenEvents() { v.prevGroup.Add(len(v.handlers)) - for _, h := range v.handlers { + for i := range v.handlers { + h := v.handlers[i] + err := gc.workerPool.Submit(func() { h(ctx, event) v.prevGroup.Done()