forked from TrueCloudLab/neoneo-go
Merge pull request #3325 from stepanovdmitrii/fix/tcp_peer_deadlock
tcp_peer: Fix possible goroutine leak
This commit is contained in:
commit
be17924ef8
1 changed files with 6 additions and 1 deletions
|
@ -164,6 +164,7 @@ func (p *TCPPeer) handleConn() {
|
||||||
err = p.SendVersion()
|
err = p.SendVersion()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
r := io.NewBinReaderFromIO(p.conn)
|
r := io.NewBinReaderFromIO(p.conn)
|
||||||
|
loop:
|
||||||
for {
|
for {
|
||||||
msg := &Message{StateRootInHeader: p.server.config.StateRootInHeader}
|
msg := &Message{StateRootInHeader: p.server.config.StateRootInHeader}
|
||||||
err = msg.Decode(r)
|
err = msg.Decode(r)
|
||||||
|
@ -174,7 +175,11 @@ func (p *TCPPeer) handleConn() {
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
p.incoming <- msg
|
select {
|
||||||
|
case p.incoming <- msg:
|
||||||
|
case <-p.done:
|
||||||
|
break loop
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
p.Disconnect(err)
|
p.Disconnect(err)
|
||||||
|
|
Loading…
Reference in a new issue