network: set timeout on write
Fix a bug occuring under high load when node hangs during this write.
This commit is contained in:
parent
5bd6c1e5cc
commit
84a3474fc5
1 changed files with 5 additions and 0 deletions
|
@ -195,6 +195,7 @@ func (p *TCPPeer) handleQueues() {
|
|||
var p2pSkipCounter uint32
|
||||
const p2pSkipDivisor = 4
|
||||
|
||||
var writeTimeout = time.Duration(p.server.chain.GetConfig().SecondsPerBlock) * time.Second
|
||||
for {
|
||||
var msg []byte
|
||||
|
||||
|
@ -228,6 +229,10 @@ func (p *TCPPeer) handleQueues() {
|
|||
case msg = <-p.sendQ:
|
||||
}
|
||||
}
|
||||
err = p.conn.SetWriteDeadline(time.Now().Add(writeTimeout))
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
_, err = p.conn.Write(msg)
|
||||
if err != nil {
|
||||
break
|
||||
|
|
Loading…
Reference in a new issue