peer: ensure the chanMsgStream for a channel exists on peer d/c

This commit is contained in:
Olaoluwa Osuntokun 2017-07-31 21:31:16 -07:00
parent c47408119e
commit 0377a4f99d
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2
1 changed files with 14 additions and 0 deletions

14
peer.go
View File

@ -441,6 +441,9 @@ func (c *chanMsgStream) Stop() {
// TODO(roasbeef): signal too?
close(c.quit)
// Wake up the msgConsumer is we've been signalled to exit.
c.msgCond.Signal()
}
// msgConsumer is the main goroutine that streams messages from the peer's
@ -454,6 +457,17 @@ func (c *chanMsgStream) msgConsumer() {
c.msgCond.L.Lock()
for len(c.msgs) == 0 {
c.msgCond.Wait()
// If we were woke up in order to exit, then we'll do
// so. Otherwise, we'll check the message queue for any
// new items.
select {
case <-c.quit:
peerLog.Tracef("Update stream for "+
"ChannelID(%x) exiting", c.cid[:])
return
default:
}
}
// Grab the message off the front of the queue, shifting the