mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-29 15:11:09 +02:00
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:
@@ -538,6 +538,9 @@ func (m *SyncManager) syncerHandler(ctx context.Context) {
|
||||
|
||||
case <-m.quit:
|
||||
return
|
||||
|
||||
case <-ctx.Done():
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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:
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user