Merge pull request #3325 from stepanovdmitrii/fix/tcp_peer_deadlock

tcp_peer: Fix possible goroutine leak
This commit is contained in:
Anna Shaleva 2024-02-26 12:12:28 +03:00 committed by GitHub
commit be17924ef8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -164,6 +164,7 @@ func (p *TCPPeer) handleConn() {
err = p.SendVersion()
if err == nil {
r := io.NewBinReaderFromIO(p.conn)
loop:
for {
msg := &Message{StateRootInHeader: p.server.config.StateRootInHeader}
err = msg.Decode(r)
@ -174,7 +175,11 @@ func (p *TCPPeer) handleConn() {
} else if err != nil {
break
}
p.incoming <- msg
select {
case p.incoming <- msg:
case <-p.done:
break loop
}
}
}
p.Disconnect(err)