From 0377a4f99de4a533eaffafcda6e47354db566be2 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Mon, 31 Jul 2017 21:31:16 -0700 Subject: [PATCH] peer: ensure the chanMsgStream for a channel exists on peer d/c --- peer.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/peer.go b/peer.go index a9a01005..39e62dde 100644 --- a/peer.go +++ b/peer.go @@ -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