@@ -3804,18 +3804,28 @@ func (p *Brontide) chanFlushEventSentinel(chanCloser *chancloser.RbfChanCloser,
3804
3804
// We'll wait until the channel enters the ChannelFlushing state. We
3805
3805
// exit after a success loop. As after the first RBF iteration, the
3806
3806
// channel will always be flushed.
3807
- for newState := range newStateChan {
3808
- if _ , ok := newState .(* chancloser.ChannelFlushing ); ok {
3809
- peerLog .Infof ("ChannelPoint(%v): rbf coop " +
3810
- "close is awaiting a flushed state, " +
3811
- "registering with link..., " ,
3812
- channel .ChannelPoint ())
3813
-
3814
- // Request the link to send the event once the channel
3815
- // is flushed. We only need this event sent once, so we
3816
- // can exit now.
3817
- link .OnFlushedOnce (sendChanFlushed )
3807
+ for {
3808
+ select {
3809
+ case newState , ok := <- newStateChan :
3810
+ if ! ok {
3811
+ return
3812
+ }
3813
+
3814
+ if _ , ok := newState .(* chancloser.ChannelFlushing ); ok {
3815
+ peerLog .Infof ("ChannelPoint(%v): rbf coop " +
3816
+ "close is awaiting a flushed state, " +
3817
+ "registering with link..., " ,
3818
+ channel .ChannelPoint ())
3818
3819
3820
+ // Request the link to send the event once the
3821
+ // channel is flushed. We only need this event
3822
+ // sent once, so we can exit now.
3823
+ link .OnFlushedOnce (sendChanFlushed )
3824
+
3825
+ return
3826
+ }
3827
+
3828
+ case <- p .cg .Done ():
3819
3829
return
3820
3830
}
3821
3831
}
0 commit comments