contractcourt: ensure we always cancel block epoch notifications after use
In this commit, we fix an existing grouting leak within the contract court package. If a goroutine dies, but it doesn’t actually cancel the block epoch notification that it requested, then it’s possible to leak thousands of gorutines. To remedy this situation, we ensure that we’ll *always* cancel the epoch notification once the goroutine has exited.
This commit is contained in:
parent
30dbbd69a0
commit
2099d6fa77
@ -395,6 +395,7 @@ func (c *ChainArbitrator) Start() error {
|
|||||||
c.chanSource.DB, arbCfg, c.cfg.ChainHash, chanPoint,
|
c.chanSource.DB, arbCfg, c.cfg.ChainHash, chanPoint,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
blockEpoch.Cancel()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
arbCfg.MarkChannelResolved = func() error {
|
arbCfg.MarkChannelResolved = func() error {
|
||||||
|
@ -865,6 +865,8 @@ func (h *htlcOutgoingContestResolver) Resolve() (ContractResolver, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
defer blockEpochs.Cancel()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
|
|
||||||
@ -1058,7 +1060,10 @@ func (h *htlcIncomingContestResolver) Resolve() (ContractResolver, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer preimageSubscription.CancelSubcription()
|
defer func() {
|
||||||
|
preimageSubscription.CancelSubcription()
|
||||||
|
blockEpochs.Cancel()
|
||||||
|
}()
|
||||||
for {
|
for {
|
||||||
|
|
||||||
select {
|
select {
|
||||||
|
Loading…
Reference in New Issue
Block a user