Fix locks in worker-tracked

This commit is contained in:
Łukasz Magiera 2021-10-18 20:19:21 +02:00
parent 70589e4406
commit 080aa3356a

View File

@ -73,6 +73,9 @@ func (wt *workTracker) track(ctx context.Context, ready chan struct{}, wid Worke
} }
} }
wt.lk.Lock()
defer wt.lk.Unlock()
select { select {
case <-ready: case <-ready:
case <-ctx.Done(): 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.prepared[prepID] = tracked(storiface.RWPrepared, storiface.UndefCall)
wt.lk.Unlock() wt.lk.Unlock()
select { select {
case <-ready: case <-ready:
case <-ctx.Done(): case <-ctx.Done():
@ -100,8 +104,7 @@ func (wt *workTracker) track(ctx context.Context, ready chan struct{}, wid Worke
return callID, err return callID, err
} }
wt.lk.Lock()
defer wt.lk.Unlock()
_, done := wt.done[callID] _, done := wt.done[callID]
if done { if done {