From e5163d1e050ec80ded49c6f8ff2360591b89ef23 Mon Sep 17 00:00:00 2001 From: Zsolt Felfoldi Date: Sat, 14 Sep 2019 03:28:59 +0200 Subject: [PATCH] les: fixed clientPool.setLimits --- les/clientpool.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/les/clientpool.go b/les/clientpool.go index b16c7202ae..6773aab551 100644 --- a/les/clientpool.go +++ b/les/clientpool.go @@ -366,12 +366,14 @@ func (f *clientPool) setLimits(count int, totalCap uint64) { f.countLimit = count f.capacityLimit = totalCap - now := mclock.Now() - f.connectedQueue.MultiPop(func(data interface{}, priority int64) bool { - c := data.(*clientInfo) - f.dropClient(c, now, true) - return f.connectedCapacity > f.capacityLimit || f.connectedQueue.Size() > f.countLimit - }) + if f.connectedCapacity > f.capacityLimit || f.connectedQueue.Size() > f.countLimit { + now := mclock.Now() + f.connectedQueue.MultiPop(func(data interface{}, priority int64) bool { + c := data.(*clientInfo) + 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.