[9.20] fix: dev: Don't skip the counting if fcount_incr() is called with force==true (v2)

The fcount_incr() was not increasing counter->count when force was set
to true, but fcount_decr() would try to decrease the counter leading to
underflow and assertion failure.  Swap the order of the arguments in the
condition, so the !force is evaluated after incrementing the .count.

Closes #4846

Backport of MR !9298

Merge branch 'backport-4786-forced-fcount_incr-should-increment-count-and-allowed-fix-9.20' into 'bind-9.20'

See merge request isc-projects/bind9!9299
This commit is contained in:
Ondřej Surý 2024-08-13 14:53:28 +00:00
commit 1db5c6a0d3
2 changed files with 2 additions and 1 deletions

View file

@ -27,6 +27,7 @@ options {
resolver-query-timeout 30000; # 30 seconds
dnssec-validation no;
disable-empty-zone 10.in-addr.arpa;
fetches-per-zone 40;
};
key rndc_key {

View file

@ -1487,7 +1487,7 @@ fcount_incr(fetchctx_t *fctx, bool force) {
INSIST(spill > 0);
LOCK(&counter->lock);
if (!force && ++counter->count > spill) {
if (++counter->count > spill && !force) {
counter->count--;
INSIST(counter->count > 0);
counter->dropped++;