Skip to content

Fix reference counting in do_nsfetch()

Michał Kępień requested to merge 4213-fix-reference-counting-in-do_nsfetch into main

Each function queuing a do_nsfetch() call using isc_async_run() is expected to increase the given zone's internal reference count (zone->irefs), which is then correspondingly decreased in either do_nsfetch() itself (when the dns_resolver_createfetch() fails) or in nsfetch_done() (when recursion is finished).

However, do_nsfetch() can also return early if either the zone itself or the relevant view's resolver object is being shut down. In that case, do_nsfetch() simply returns without decreasing the internal reference count for the zone. This leaves a dangling zone reference, which leads to hangs during named shutdown.

Fix by executing the same cleanup code for early returns from do_nsfetch() as for a failed dns_resolver_createfetch() call in that function as the reference count will not be decreased in nsfetch_done() in any of these cases.

Closes #4213 (closed)

Merge request reports