From 080aa3356af67b1db863f991ec22f975c9a81c21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Mon, 18 Oct 2021 20:19:21 +0200 Subject: [PATCH] Fix locks in worker-tracked --- extern/sector-storage/worker_tracked.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/extern/sector-storage/worker_tracked.go b/extern/sector-storage/worker_tracked.go index 2ebc5b620..b45c4237c 100644 --- a/extern/sector-storage/worker_tracked.go +++ b/extern/sector-storage/worker_tracked.go @@ -73,6 +73,9 @@ func (wt *workTracker) track(ctx context.Context, ready chan struct{}, wid Worke } } + wt.lk.Lock() + defer wt.lk.Unlock() + select { case <-ready: case <-ctx.Done(): @@ -83,6 +86,7 @@ func (wt *workTracker) track(ctx context.Context, ready chan struct{}, wid Worke wt.prepared[prepID] = tracked(storiface.RWPrepared, storiface.UndefCall) wt.lk.Unlock() + select { case <-ready: case <-ctx.Done(): @@ -100,8 +104,7 @@ func (wt *workTracker) track(ctx context.Context, ready chan struct{}, wid Worke return callID, err } - wt.lk.Lock() - defer wt.lk.Unlock() + _, done := wt.done[callID] if done {