Commit eb8a2737 authored by Michał Kępień's avatar Michał Kępień Committed by Ondřej Surý
Browse files

Ensure ns_query_cancel() handles all recursions

Previously, multiple code paths reused client->query.fetch, so it was
enough for ns_query_cancel() to issue a single call to
dns_resolver_cancelfetch() with that fetch as an argument.  Now, since
each slot in the 'recursions' array can hold a reference to a separate
resolver fetch, ns_query_cancel() needs to handle all of them, so that
all recursion callbacks get a chance to clean up the associated
resources when a query is canceled.
parent 1a635b54
Pipeline #104895 failed with stages
in 25 minutes and 26 seconds
...@@ -658,12 +658,14 @@ query_freefreeversions(ns_client_t *client, bool everything) { ...@@ -658,12 +658,14 @@ query_freefreeversions(ns_client_t *client, bool everything) {
void void
ns_query_cancel(ns_client_t *client) { ns_query_cancel(ns_client_t *client) {
dns_fetch_t **fetchp = &client->query.recursions[RECTYPE_NORMAL].fetch;
LOCK(&client->query.fetchlock); LOCK(&client->query.fetchlock);
if (*fetchp != NULL) { for (int i = 0; i < RECTYPE_COUNT; i++) {
dns_resolver_cancelfetch(*fetchp); dns_fetch_t **fetchp = &client->query.recursions[i].fetch;
*fetchp = NULL; if (*fetchp != NULL) {
*fetchp = NULL;
} }
if (client->query.hookactx != NULL) { if (client->query.hookactx != NULL) {
client->query.hookactx->cancel(client->query.hookactx); client->query.hookactx->cancel(client->query.hookactx);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment