Skip to content

Commit 00338c5

Browse files
committed
discovery: properly handle SyncManager shutdown signal
1 parent 46ceaf8 commit 00338c5

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

discovery/sync_manager.go

+14
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,13 @@ func (m *SyncManager) roundRobinHandler() {
286286
current = m.nextPendingActiveSyncer()
287287
m.Unlock()
288288
for current != nil {
289+
// Ensure we properly handle a shutdown signal.
290+
select {
291+
case <-m.quit:
292+
return
293+
default:
294+
}
295+
289296
// We'll avoid performing the transition with the lock
290297
// as it can potentially stall the SyncManager due to
291298
// the syncTransitionTimeout.
@@ -531,6 +538,13 @@ func (m *SyncManager) forceHistoricalSync() {
531538
candidatesChosen := make(map[routing.Vertex]struct{})
532539
s := m.chooseRandomSyncer(candidatesChosen, true)
533540
for s != nil {
541+
// Ensure we properly handle a shutdown signal.
542+
select {
543+
case <-m.quit:
544+
return
545+
default:
546+
}
547+
534548
// Blacklist the candidate to ensure it's not chosen again.
535549
candidatesChosen[s.cfg.peerPub] = struct{}{}
536550

0 commit comments

Comments
 (0)