mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 09:53:54 +01:00
htlcswitch: fix notifier goroutine leak by cancelling epoch when htlcManager exits
Before this commit, if the htlcManager unexpectedly exited (due to a protocol error, etc), the underlying block epoch notification intent that was created for it would never be cancelled. This would result in tens, or hundreds of goroutine leaks as the client would never consume those notifications. To fix this, we move cancellation of the block epoch intent from the Stop() method of the channel link, to the defer statement at the top of the htlcManager.
This commit is contained in:
parent
795b5559f0
commit
912366ada5
@ -289,7 +289,6 @@ func (l *channelLink) Stop() {
|
||||
close(l.quit)
|
||||
l.wg.Wait()
|
||||
|
||||
l.cfg.BlockEpochs.Cancel()
|
||||
}
|
||||
|
||||
// EligibleToForward returns a bool indicating if the channel is able to
|
||||
@ -355,6 +354,7 @@ func shouldAdjustCommitFee(netFee, chanFee btcutil.Amount) bool {
|
||||
func (l *channelLink) htlcManager() {
|
||||
defer func() {
|
||||
l.wg.Done()
|
||||
l.cfg.BlockEpochs.Cancel()
|
||||
log.Infof("ChannelLink(%v) has exited", l)
|
||||
}()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user