Skip to content

Commit e593c9d

Browse files
committed
brontide: fix peer disconnection issue
In case when the rbf coop close feature was active we would not properly disconnect the peer.
1 parent b837c88 commit e593c9d

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

peer/brontide.go

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3804,18 +3804,28 @@ func (p *Brontide) chanFlushEventSentinel(chanCloser *chancloser.RbfChanCloser,
38043804
// We'll wait until the channel enters the ChannelFlushing state. We
38053805
// exit after a success loop. As after the first RBF iteration, the
38063806
// 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())
38183819

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():
38193829
return
38203830
}
38213831
}

0 commit comments

Comments
 (0)