From 632f230fef474dc596c44d92841fbcf10efad7b0 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Fri, 10 Nov 2017 19:37:47 -0800 Subject: [PATCH] htlcswitch: add quit case to initial channel state sync select in channelLink MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In this commit we add a quit case to the select statement that’s entered once a link is created. Before this commit, upon restart it would be possible that the deamon would never ben able to shutdown as the link would be waiting for the messages to be sent by the other side. --- htlcswitch/link.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/htlcswitch/link.go b/htlcswitch/link.go index 65201198..7400545b 100644 --- a/htlcswitch/link.go +++ b/htlcswitch/link.go @@ -297,7 +297,10 @@ func (l *channelLink) Stop() { // // NOTE: This MUST be run as a goroutine. func (l *channelLink) htlcManager() { - defer l.wg.Done() + defer func() { + l.wg.Done() + log.Infof("ChannelLink(%v) has exited", l) + }() log.Infof("HTLC manager for ChannelPoint(%v) started, "+ "bandwidth=%v", l.channel.ChannelPoint(), l.Bandwidth()) @@ -367,6 +370,8 @@ func (l *channelLink) htlcManager() { // In any case, we'll then process their ChanSync // message. l.handleUpstreamMsg(msg) + case <-l.quit: + return case <-chanSyncDeadline: l.fail("didn't receive ChannelReestablish before " + "deadline") @@ -534,8 +539,6 @@ out: break out } } - - log.Infof("ChannelLink(%v) has exited", l) } // handleDownStreamPkt processes an HTLC packet sent from the downstream HTLC