Skip to content

Commit 1dd67cb

Browse files
committed
Cancel parent context when aborting bootstrapping
Signed-off-by: Yacov Manevich <yacov.manevich@avalabs.org>
1 parent 4c46441 commit 1dd67cb

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

chains/manager.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,8 @@ type manager struct {
262262
// processed.
263263
chainCreatorShutdownCh chan struct{}
264264
chainCreatorExited sync.WaitGroup
265+
context context.Context
266+
cancelContext context.CancelFunc
265267

266268
chainsLock sync.Mutex
267269
// Key: Chain's ID
@@ -324,7 +326,11 @@ func New(config *ManagerConfig) (Manager, error) {
324326
return nil, err
325327
}
326328

329+
ctx, cancelContext := context.WithCancel(context.Background())
330+
327331
return &manager{
332+
context: ctx,
333+
cancelContext: cancelContext,
328334
Aliaser: ids.NewAliaser(),
329335
ManagerConfig: *config,
330336
chains: make(map[ids.ID]handler.Handler),
@@ -468,7 +474,7 @@ func (m *manager) createChain(chainParams ChainParameters) {
468474

469475
// Tell the chain to start processing messages.
470476
// If the X, P, or C Chain panics, do not attempt to recover
471-
chain.Handler.Start(context.TODO(), !m.CriticalChains.Contains(chainParams.ID))
477+
chain.Handler.Start(m.context, !m.CriticalChains.Contains(chainParams.ID))
472478
}
473479

474480
// Create a chain
@@ -1523,6 +1529,7 @@ func (m *manager) Shutdown() {
15231529
m.Log.Info("shutting down chain manager")
15241530
m.chainsQueue.Close()
15251531
close(m.chainCreatorShutdownCh)
1532+
m.cancelContext()
15261533
m.chainCreatorExited.Wait()
15271534
m.ManagerConfig.Router.Shutdown(context.TODO())
15281535
}

0 commit comments

Comments
 (0)