Commit 0f5cc8bd authored by Steven Allen's avatar Steven Allen

fix a startup race by creating the blockstoremanager process on init

parent 47b99b1c
...@@ -26,24 +26,24 @@ func newBlockstoreManager(bs bstore.Blockstore, workerCount int) *blockstoreMana ...@@ -26,24 +26,24 @@ func newBlockstoreManager(bs bstore.Blockstore, workerCount int) *blockstoreMana
bs: bs, bs: bs,
workerCount: workerCount, workerCount: workerCount,
jobs: make(chan func()), jobs: make(chan func()),
px: process.WithTeardown(func() error { return nil }),
} }
} }
func (bsm *blockstoreManager) start(px process.Process) { func (bsm *blockstoreManager) start(px process.Process) {
bsm.px = px px.AddChild(bsm.px)
// Start up workers // Start up workers
for i := 0; i < bsm.workerCount; i++ { for i := 0; i < bsm.workerCount; i++ {
px.Go(func(px process.Process) { bsm.px.Go(func(px process.Process) {
bsm.worker() bsm.worker(px)
}) })
} }
} }
func (bsm *blockstoreManager) worker() { func (bsm *blockstoreManager) worker(px process.Process) {
for { for {
select { select {
case <-bsm.px.Closing(): case <-px.Closing():
return return
case job := <-bsm.jobs: case job := <-bsm.jobs:
job() 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