update limiter
This commit is contained in:
@ -102,7 +102,7 @@ type connLimiter struct {
|
||||
ipLimits map[string]ConnLimitGenerator
|
||||
cidrLimits cidranger.Ranger
|
||||
limits map[string]limiter.Limiter
|
||||
mu sync.RWMutex
|
||||
mu sync.Mutex
|
||||
cancelFunc context.CancelFunc
|
||||
options options
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ func (l *llimiter) Limit() int {
|
||||
}
|
||||
|
||||
func (l *llimiter) Allow(n int) bool {
|
||||
if atomic.AddInt64(&l.current, int64(n)) >= int64(l.limit) {
|
||||
if atomic.AddInt64(&l.current, int64(n)) > int64(l.limit) {
|
||||
if n > 0 {
|
||||
atomic.AddInt64(&l.current, -int64(n))
|
||||
}
|
||||
|
Reference in New Issue
Block a user