Skip to content

Commit

Permalink
Merge pull request #834 from sputn1ck/fix_select
Browse files Browse the repository at this point in the history
reservations: check if channel is closing
  • Loading branch information
sputn1ck authored Oct 16, 2024
2 parents 2c32575 + d6c7237 commit 0ab40fe
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions instantout/reservation/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,22 @@ func (m *Manager) Run(ctx context.Context, height int32) error {
return err
}

ntfnChan := m.cfg.NotificationManager.SubscribeReservations(ctx)
ntfnChan := m.cfg.NotificationManager.SubscribeReservations(runCtx)

for {
select {
case height := <-newBlockChan:
log.Debugf("Received block %v", height)
currentHeight = height

case reservationRes := <-ntfnChan:
case reservationRes, ok := <-ntfnChan:
if !ok {
// The channel has been closed, we'll stop the
// reservation manager.
log.Debugf("Stopping reservation manager (ntfnChan closed)")
return nil
}

log.Debugf("Received reservation %x",
reservationRes.ReservationId)
_, err := m.newReservation(
Expand Down

0 comments on commit 0ab40fe

Please sign in to comment.