Unverified Commit d1d4afa2 authored by Steven Allen's avatar Steven Allen Committed by GitHub

Merge pull request #465 from ipfs/fix/startup-race

fix a startup race by creating the blockstoremanager process on init
parents 47b99b1c 0f5cc8bd
......@@ -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()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment