peer: raise readHandler wait group done to defer statement

In this commit, we raise the readHandler wait group done into a defer
statement at the top of the method. This fixes an existing but that
would cause the readHandler to declare it had exited, yet possibly still
be waiting on the chan message stream below to exit.
This commit is contained in:
Olaoluwa Osuntokun 2018-08-24 17:49:12 -07:00
parent 5cf911a762
commit ce115a6a59

View File

@ -878,6 +878,7 @@ func newDiscMsgStream(p *peer) *msgStream {
//
// NOTE: This method MUST be run as a goroutine.
func (p *peer) readHandler() {
defer p.wg.Done()
// We'll stop the timer after a new messages is received, and also
// reset it after we process the next message.
@ -1066,8 +1067,6 @@ out:
idleTimer.Reset(idleTimeout)
}
p.wg.Done()
p.Disconnect(errors.New("read handler closed"))
for cid, chanStream := range chanMsgStreams {