Skip to content

Commit 0ab40fe

Browse files
authored
Merge pull request #834 from sputn1ck/fix_select
reservations: check if channel is closing
2 parents 2c32575 + d6c7237 commit 0ab40fe

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

instantout/reservation/manager.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,22 @@ func (m *Manager) Run(ctx context.Context, height int32) error {
5656
return err
5757
}
5858

59-
ntfnChan := m.cfg.NotificationManager.SubscribeReservations(ctx)
59+
ntfnChan := m.cfg.NotificationManager.SubscribeReservations(runCtx)
6060

6161
for {
6262
select {
6363
case height := <-newBlockChan:
6464
log.Debugf("Received block %v", height)
6565
currentHeight = height
6666

67-
case reservationRes := <-ntfnChan:
67+
case reservationRes, ok := <-ntfnChan:
68+
if !ok {
69+
// The channel has been closed, we'll stop the
70+
// reservation manager.
71+
log.Debugf("Stopping reservation manager (ntfnChan closed)")
72+
return nil
73+
}
74+
6875
log.Debugf("Received reservation %x",
6976
reservationRes.ReservationId)
7077
_, err := m.newReservation(

0 commit comments

Comments
 (0)