network: drain send queues on peer disconnection
Fix potential memory leak with a lot of connected clients that keep requesting things from node and then disconnect.
This commit is contained in:
parent
510bc91804
commit
4f708c037d
1 changed files with 10 additions and 0 deletions
|
@ -250,6 +250,16 @@ func (p *TCPPeer) handleQueues() {
|
||||||
p2pSkipCounter++
|
p2pSkipCounter++
|
||||||
}
|
}
|
||||||
p.Disconnect(err)
|
p.Disconnect(err)
|
||||||
|
drainloop:
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-p.hpSendQ:
|
||||||
|
case <-p.p2pSendQ:
|
||||||
|
case <-p.sendQ:
|
||||||
|
default:
|
||||||
|
break drainloop
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// StartProtocol starts a long running background loop that interacts
|
// StartProtocol starts a long running background loop that interacts
|
||||||
|
|
Loading…
Reference in a new issue