Skip to content

Commit e302fd0

Browse files
committed
discovery: check context for cancellation
1 parent 9a7b526 commit e302fd0

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

discovery/syncer.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,21 @@ func (g *GossipSyncer) channelGraphSyncer(ctx context.Context) {
532532
defer g.cg.WgDone()
533533

534534
for {
535+
// Check cancellation before processing any state.
536+
select {
537+
case <-ctx.Done():
538+
log.Debugf("GossipSyncer(%x): context canceled, "+
539+
"exiting", g.cfg.peerPub[:])
540+
541+
return
542+
case <-g.cg.Done():
543+
log.Debugf("GossipSyncer(%x): shutting down",
544+
g.cfg.peerPub[:])
545+
546+
return
547+
default:
548+
}
549+
535550
state := g.syncState()
536551
syncType := g.SyncType()
537552

0 commit comments

Comments
 (0)