From e5b74174b596aa8d3e32550f309ee9725b993706 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Tue, 9 Jan 2018 12:18:57 -0800 Subject: [PATCH] pilot: avoid cancelling the tx subscription twice, use proper wg value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- pilot.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pilot.go b/pilot.go index b407fe51..ad239ef6 100644 --- a/pilot.go +++ b/pilot.go @@ -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 {