Skip to content

Commit

Permalink
Merge pull request ipfs/go-bitswap#504 from ipfs/fix/task-worker-coun…
Browse files Browse the repository at this point in the history
…t-race

fix: hold the task worker lock when starting task workers

This commit was moved from ipfs/go-bitswap@d48cee0
  • Loading branch information
Stebalien authored Jun 24, 2021
2 parents d496037 + 0f4401d commit 8c62bb5
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions bitswap/internal/decision/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ func (e *Engine) StartWorkers(ctx context.Context, px process.Process) {
e.bsm.start(px)
e.startScoreLedger(px)

e.taskWorkerLock.Lock()
defer e.taskWorkerLock.Unlock()

for i := 0; i < e.taskWorkerCount; i++ {
px.Go(func(px process.Process) {
e.taskWorker(ctx)
Expand Down

0 comments on commit 8c62bb5

Please sign in to comment.