les: fixed clientPool.setLimits

This commit is contained in:
Zsolt Felfoldi 2019-09-14 03:28:59 +02:00
parent 0cbf1d89af
commit a094623a10

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
now := mclock.Now() if f.connectedCapacity > f.capacityLimit || f.connectedQueue.Size() > f.countLimit {
f.connectedQueue.MultiPop(func(data interface{}, priority int64) bool { now := mclock.Now()
c := data.(*clientInfo) f.connectedQueue.MultiPop(func(data interface{}, priority int64) bool {
f.dropClient(c, now, true) c := data.(*clientInfo)
return f.connectedCapacity > f.capacityLimit || f.connectedQueue.Size() > f.countLimit f.dropClient(c, now, true)
}) 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.