discovery: listen on ctx in any select

For any method that takes a context that has a select that listens on
the systems quit channel, we should also listen on the ctx since we
should not need to worry about if this context is derived internally or
externally.
This commit is contained in:
Elle Mouton
2025-04-09 15:08:46 +02:00
parent 6d03df7b26
commit 3162837c32
2 changed files with 19 additions and 0 deletions

View File

@@ -538,6 +538,9 @@ func (m *SyncManager) syncerHandler(ctx context.Context) {
case <-m.quit:
return
case <-ctx.Done():
return
}
}
}

View File

@@ -527,6 +527,9 @@ func (g *GossipSyncer) channelGraphSyncer(ctx context.Context) {
case <-g.cg.Done():
return
case <-ctx.Done():
return
}
// We'll enter this state once we've discovered which channels
@@ -577,6 +580,9 @@ func (g *GossipSyncer) channelGraphSyncer(ctx context.Context) {
case <-g.cg.Done():
return
case <-ctx.Done():
return
}
// This is our final terminal state where we'll only reply to
@@ -623,6 +629,9 @@ func (g *GossipSyncer) channelGraphSyncer(ctx context.Context) {
case <-g.cg.Done():
return
case <-ctx.Done():
return
}
}
}
@@ -656,6 +665,9 @@ func (g *GossipSyncer) replyHandler(ctx context.Context) {
case <-g.cg.Done():
return
case <-ctx.Done():
return
}
}
}
@@ -1298,6 +1310,8 @@ func (g *GossipSyncer) ApplyGossipFilter(ctx context.Context,
case <-g.syncerSema:
case <-g.cg.Done():
return ErrGossipSyncerExiting
case <-ctx.Done():
return ctx.Err()
}
// We don't put this in a defer because if the goroutine is launched,
@@ -1370,6 +1384,8 @@ func (g *GossipSyncer) FilterGossipMsgs(ctx context.Context,
select {
case <-g.cg.Done():
return
case <-ctx.Done():
return
default:
}