mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-22 22:25:24 +01:00
pilot: fix goroutine leak by also draining UnconfirmedTransactions notifications
This commit is contained in:
parent
95de109844
commit
e19614ff3f
1 changed files with 18 additions and 0 deletions
18
pilot.go
18
pilot.go
|
@ -197,6 +197,24 @@ func initAutoPilot(svr *server, cfg *autoPilotConfig) (*autopilot.Agent, error)
|
|||
}
|
||||
}
|
||||
|
||||
}()
|
||||
go func() {
|
||||
defer txnSubscription.Cancel()
|
||||
defer svr.wg.Done()
|
||||
|
||||
for {
|
||||
select {
|
||||
// We won't act upon new unconfirmed transaction, as
|
||||
// we'll only use confirmed outputs when funding.
|
||||
// However, we will still drain this request in order
|
||||
// to avoid goroutine leaks, and ensure we promptly
|
||||
// read from the channel if available.
|
||||
case <-txnSubscription.UnconfirmedTransactions():
|
||||
case <-svr.quit:
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
}()
|
||||
|
||||
// We'll also launch a goroutine to provide the agent with
|
||||
|
|
Loading…
Add table
Reference in a new issue