Skip to content

Commit 38d7401

Browse files
authored
Merge pull request #942 from starius/sweepReq
staticaddr: fix crash in loop-in manager shutdown
2 parents 890b91c + 9f971cd commit 38d7401

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

staticaddr/loopin/manager.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,14 +205,25 @@ func (m *Manager) Run(ctx context.Context) error {
205205
case request.respChan <- resp:
206206

207207
case <-ctx.Done():
208-
// Noify subroutines that the main loop has been
209-
// canceled.
208+
// Notify subroutines that the main loop has
209+
// been canceled.
210210
close(m.exitChan)
211211

212212
return ctx.Err()
213213
}
214214

215-
case sweepReq := <-sweepReqs:
215+
case sweepReq, ok := <-sweepReqs:
216+
if !ok {
217+
// The channel has been closed, we'll stop the
218+
// loop-in manager.
219+
log.Debugf("Stopping loop-in manager " +
220+
"(ntfnChan closed)")
221+
222+
close(m.exitChan)
223+
224+
return fmt.Errorf("ntfnChan closed")
225+
}
226+
216227
err = m.handleLoopInSweepReq(ctx, sweepReq)
217228
if err != nil {
218229
log.Errorf("Error handling loop-in sweep "+

0 commit comments

Comments
 (0)