pilot: fix goroutine leak by also draining UnconfirmedTransactions notifications

This commit is contained in:
Olaoluwa Osuntokun 2018-01-08 17:44:28 -08:00
parent 95de109844
commit e19614ff3f
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21

View File

@ -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