pilot: avoid cancelling the tx subscription twice, use proper wg value

In this commit we fix a newly introduce bug wherein we would close the
transaction subscription twice on shutdown. This would lead to a
shutdown, but an unclean one as it would panic due to closing a channel
twice.

We fix this my removing a defer statement such that, we’ll only cancel
the subscription once.
This commit is contained in:
Olaoluwa Osuntokun 2018-01-09 12:18:57 -08:00
parent 9a76b3ee58
commit e5b74174b5
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21

View File

@ -183,7 +183,7 @@ func initAutoPilot(svr *server, cfg *autoPilotConfig) (*autopilot.Agent, error)
// We'll launch a goroutine to provide the agent with notifications
// whenever the balance of the wallet changes.
svr.wg.Add(1)
svr.wg.Add(2)
go func() {
defer txnSubscription.Cancel()
defer svr.wg.Done()
@ -199,7 +199,6 @@ func initAutoPilot(svr *server, cfg *autoPilotConfig) (*autopilot.Agent, error)
}()
go func() {
defer txnSubscription.Cancel()
defer svr.wg.Done()
for {