Panics while decoding messages in connection.mainLoopRead would trigger more panics

This commit is contained in:
Matt Joiner 2017-08-31 16:25:49 +10:00
parent cf022be396
commit c4f5a49c97
1 changed files with 9 additions and 4 deletions

View File

@ -749,10 +749,15 @@ func (c *connection) mainReadLoop() error {
Pool: t.chunkPool,
}
for {
cl.mu.Unlock()
var msg pp.Message
err := decoder.Decode(&msg)
cl.mu.Lock()
var (
msg pp.Message
err error
)
func() {
cl.mu.Unlock()
defer cl.mu.Lock()
err = decoder.Decode(&msg)
}()
if cl.closed.IsSet() || c.closed.IsSet() || err == io.EOF {
return nil
}