Merge pull request #2924 from nspcc-dev/drain-queues-on-disconnect

network: drain send queues on peer disconnection
This commit is contained in:
Roman Khimov 2023-02-21 17:12:23 +03:00 committed by GitHub
commit 31ee21a83a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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