summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorDylan William Hardison <dylan@hardison.net>2018-07-02 23:09:51 +0200
committerGitHub <noreply@github.com>2018-07-02 23:09:51 +0200
commit67a2d43f4c270a33112e36cb26704cf995bcd6e6 (patch)
treeb5533fee85c725026ba11c337cd79b50547eb885 /Bugzilla
parent3cc222bb9a02ff33e5296a5d257d49173f656506 (diff)
downloadbugzilla-67a2d43f4c270a33112e36cb26704cf995bcd6e6.tar.gz
bugzilla-67a2d43f4c270a33112e36cb26704cf995bcd6e6.tar.xz
Bug 1472755 - False positives on IP blocking logic
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/Memcached.pm6
1 files changed, 4 insertions, 2 deletions
diff --git a/Bugzilla/Memcached.pm b/Bugzilla/Memcached.pm
index d34aaa595..f3272c194 100644
--- a/Bugzilla/Memcached.pm
+++ b/Bugzilla/Memcached.pm
@@ -227,11 +227,12 @@ sub should_rate_limit {
my $prefix = RATE_LIMIT_PREFIX . $name . ':';
my $memcached = $self->{memcached};
+ return 0 unless $name;
return 0 unless $memcached;
$tries //= 3;
- for (0 .. $tries) {
+ for my $try (0 .. $tries) {
my $now = time;
my ($key, @keys) = map { $prefix . ( $now - $_ ) } 0 .. $rate_seconds;
$memcached->add($key, 0, $rate_seconds+1);
@@ -240,8 +241,9 @@ sub should_rate_limit {
$tokens->{$key} = $cas->[1]++;
return 1 if sum(values %$tokens) >= $rate_max;
return 0 if $memcached->cas($key, @$cas, $rate_seconds+1);
+ WARN("retry for $prefix (try $try of $tries)");
}
- return 1;
+ return 0;
}
sub clear_all {