diff options
| author | Chris Lu <chris.lu@uber.com> | 2021-04-04 18:38:30 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@uber.com> | 2021-04-04 18:38:33 -0700 |
| commit | fbb82a5c9c3ea9aef26041f47da27bf362b132e6 (patch) | |
| tree | 01305525483bd26b2087f9154d28cfd83949e1f2 | |
| parent | 8251d1140ee8077f6b17d960000928b1d791fd18 (diff) | |
| download | seaweedfs-fbb82a5c9c3ea9aef26041f47da27bf362b132e6.tar.xz seaweedfs-fbb82a5c9c3ea9aef26041f47da27bf362b132e6.zip | |
skip limiting if limit is zero
| -rw-r--r-- | weed/util/limiter.go | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/weed/util/limiter.go b/weed/util/limiter.go index ccdaa701e..2debaaa85 100644 --- a/weed/util/limiter.go +++ b/weed/util/limiter.go @@ -85,16 +85,20 @@ func NewLimitedOutOfOrderProcessor(limit int32) (c *LimitedOutOfOrderProcessor) request := value.Interface().(OperationRequest) - c.processorLimitCond.L.Lock() - for atomic.LoadInt32(&c.currentProcessor) > c.processorLimit { - c.processorLimitCond.Wait() + if c.processorLimit > 0 { + c.processorLimitCond.L.Lock() + for atomic.LoadInt32(&c.currentProcessor) > c.processorLimit { + c.processorLimitCond.Wait() + } + atomic.AddInt32(&c.currentProcessor, 1) + c.processorLimitCond.L.Unlock() } - atomic.AddInt32(&c.currentProcessor, 1) - c.processorLimitCond.L.Unlock() go func() { - defer atomic.AddInt32(&c.currentProcessor, -1) - defer c.processorLimitCond.Signal() + if c.processorLimit > 0 { + defer atomic.AddInt32(&c.currentProcessor, -1) + defer c.processorLimitCond.Signal() + } request() }() |
