Skip to content
This repository has been archived by the owner on Feb 1, 2023. It is now read-only.

Commit

Permalink
Merge pull request #465 from ipfs/fix/startup-race
Browse files Browse the repository at this point in the history
fix a startup race by creating the blockstoremanager process on init
  • Loading branch information
Stebalien authored Feb 26, 2021
2 parents 47b99b1 + 0f5cc8b commit d1d4afa
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions internal/decision/blockstoremanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,24 @@ func newBlockstoreManager(bs bstore.Blockstore, workerCount int) *blockstoreMana
bs: bs,
workerCount: workerCount,
jobs: make(chan func()),
px: process.WithTeardown(func() error { return nil }),
}
}

func (bsm *blockstoreManager) start(px process.Process) {
bsm.px = px

px.AddChild(bsm.px)
// Start up workers
for i := 0; i < bsm.workerCount; i++ {
px.Go(func(px process.Process) {
bsm.worker()
bsm.px.Go(func(px process.Process) {
bsm.worker(px)
})
}
}

func (bsm *blockstoreManager) worker() {
func (bsm *blockstoreManager) worker(px process.Process) {
for {
select {
case <-bsm.px.Closing():
case <-px.Closing():
return
case job := <-bsm.jobs:
job()
Expand Down

0 comments on commit d1d4afa

Please sign in to comment.