]> git.ipfire.org Git - thirdparty/bind9.git/commit
Fix the statistic counter underflow in ns_client_t
authorOndřej Surý <ondrej@sury.org>
Thu, 26 Mar 2020 09:57:38 +0000 (10:57 +0100)
committerOndřej Surý <ondrej@isc.org>
Fri, 3 Apr 2020 18:22:56 +0000 (20:22 +0200)
commitcacaa94350e34b32aa76b164010d6bcc656facf5
tree8629e557247965a9b59c0a3c50c9e0ff9b3b2f8c
parent0e9b0d79fb6307a735af9a58b00e2946b12be71b
Fix the statistic counter underflow in ns_client_t

In case of normal fetch, the .recursionquota is attached and
ns_statscounter_recursclients is incremented when the fetch is created.  Then
the .recursionquota is detached and the counter decremented in the
fetch_callback().

In case of prefetch or rpzfetch, the quota is attached, but the counter is not
incremented.  When we reach the soft-quota, the function returns early but don't
detach from the quota, and it gets destroyed during the ns_client_endrequest(),
so no memory was leaked.

But because the ns_statscounter_recursclients is only incremented during the
normal fetch the counter would be incorrectly decremented on two occassions:

1) When we reached the softquota, because the quota was not properly detached
2) When the prefetch or rpzfetch was cancelled mid-flight and the callback
   function was never called.

(cherry picked from commit 78886d4bedeef3dcffa1f9eebe431f35a03f3593)
lib/ns/client.c
lib/ns/query.c