htlcswitch: add quit case to initial channel state sync select in channelLink

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.
This commit is contained in:
Olaoluwa Osuntokun 2017-11-10 19:37:47 -08:00
parent 6f51b941df
commit 632f230fef
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21
1 changed files with 6 additions and 3 deletions

View File

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