peer: avoid possible GC leak by setting popped queue element to nil

This commit is contained in:
Olaoluwa Osuntokun
2017-09-24 20:08:26 -07:00
parent 457aebd16f
commit 37d03d1e56

View File

@@ -537,6 +537,7 @@ func (c *chanMsgStream) msgConsumer() {
// slice's reference down one in order to remove the message
// from the queue.
msg := c.msgs[0]
c.msgs[0] = nil // Set to nil to prevent GC leak.
c.msgs = c.msgs[1:]
// We'll send a message to the funding manager and wait iff an
@@ -859,6 +860,9 @@ func (p *peer) queueHandler() {
// If there weren't any messages to send, or the writehandler
// is still blocked, then we'll accept a new message into the
// queue from outside sub-systems.
//
// TODO(roasbeef): need send clause here as well to account for
// writeHandler blocking?
select {
case <-p.quit:
return