les: fixed clientPool.setLimits

This commit is contained in:
Zsolt Felfoldi 2019-09-14 03:28:59 +02:00
parent c5d958e205
commit e5163d1e05

View file

@ -366,12 +366,14 @@ func (f *clientPool) setLimits(count int, totalCap uint64) {
f.countLimit = count f.countLimit = count
f.capacityLimit = totalCap f.capacityLimit = totalCap
if f.connectedCapacity > f.capacityLimit || f.connectedQueue.Size() > f.countLimit {
now := mclock.Now() now := mclock.Now()
f.connectedQueue.MultiPop(func(data interface{}, priority int64) bool { f.connectedQueue.MultiPop(func(data interface{}, priority int64) bool {
c := data.(*clientInfo) c := data.(*clientInfo)
f.dropClient(c, now, true) f.dropClient(c, now, true)
return f.connectedCapacity > f.capacityLimit || f.connectedQueue.Size() > f.countLimit return f.connectedCapacity > f.capacityLimit || f.connectedQueue.Size() > f.countLimit
}) })
}
} }
// requestCost feeds request cost after serving a request from the given peer. // requestCost feeds request cost after serving a request from the given peer.