mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-04 19:19:44 +00:00
network: set timeout on write
Fix a bug occuring under high load when node hangs during this write.
This commit is contained in:
parent
edf587bbf1
commit
9756ed2b06
1 changed files with 5 additions and 0 deletions
|
@ -178,6 +178,7 @@ func (p *TCPPeer) handleQueues() {
|
||||||
var p2pSkipCounter uint32
|
var p2pSkipCounter uint32
|
||||||
const p2pSkipDivisor = 4
|
const p2pSkipDivisor = 4
|
||||||
|
|
||||||
|
var writeTimeout = time.Duration(p.server.chain.GetConfig().SecondsPerBlock) * time.Second
|
||||||
for {
|
for {
|
||||||
var msg []byte
|
var msg []byte
|
||||||
|
|
||||||
|
@ -211,6 +212,10 @@ func (p *TCPPeer) handleQueues() {
|
||||||
case msg = <-p.sendQ:
|
case msg = <-p.sendQ:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
err = p.conn.SetWriteDeadline(time.Now().Add(writeTimeout))
|
||||||
|
if err != nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
_, err = p.conn.Write(msg)
|
_, err = p.conn.Write(msg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
break
|
break
|
||||||
|
|
Loading…
Reference in a new issue