]> git.ipfire.org Git - thirdparty/bind9.git/commit
Fix ns_statscounter_recursclients underflow
authorDiego Fronza <diego@isc.org>
Wed, 8 Jul 2020 14:42:32 +0000 (11:42 -0300)
committerDiego Fronza <diego@isc.org>
Mon, 3 Aug 2020 22:18:04 +0000 (19:18 -0300)
commitfca1000ee9257877966e7ad66e1f89435f0a1a0e
tree18d51f593430ba95263b7d23252afe53b0bca714
parent7519821f16e3ca8c951a52c90b78cf523e88128c
Fix ns_statscounter_recursclients underflow

The basic scenario for the problem was that in the process of
resolving a query, if any rrset was eligible for prefetching, then it
would trigger a call to query_prefetch(), this call would run in
parallel to the normal query processing.

The problem arises due to the fact that both query_prefetch(), and,
in the original thread, a call to ns_query_recurse(), try to attach
to the recursionquota, but recursing client stats counter is only
incremented if ns_query_recurse() attachs to it first.

Conversely, if fetch_callback() is called before prefetch_done(),
it would not only detach from recursionquota, but also decrement
the stats counter, if query_prefetch() attached to te quota first
that would result in a decrement not matched by an increment, as
expected.

To solve this issue an atomic bool was added, it is set once in
ns_query_recurse(), allowing fetch_callback() to check for it
and decrement stats accordingly.

For a more compreensive explanation check the thread comment below:
https://gitlab.isc.org/isc-projects/bind9/-/issues/1719#note_145857
lib/ns/include/ns/client.h
lib/ns/query.c