mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 14:07:59 +00:00
Make async hooks code use the 'recursions' array
Async hooks are the last feature using the client->fetchhandle and client->query.fetch pointers. Update ns_query_hookasync() and query_hookresume() so that they use a dedicated slot in the 'recursions' array. Note that async hooks are still not expected to initiate recursion if one was already started by a prior ns_query_recurse() call, so the REQUIRE assertion in ns_query_hookasync() needs to check the RECTYPE_NORMAL slot rather than the RECTYPE_HOOK one.
This commit is contained in:
@@ -46,6 +46,7 @@ typedef enum {
|
||||
RECTYPE_NORMAL,
|
||||
RECTYPE_PREFETCH,
|
||||
RECTYPE_RPZ,
|
||||
RECTYPE_HOOK,
|
||||
RECTYPE_COUNT,
|
||||
} ns_query_rectype_t;
|
||||
|
||||
@@ -59,6 +60,8 @@ typedef enum {
|
||||
((client)->query.recursions[RECTYPE_PREFETCH].handle)
|
||||
#define HANDLE_RECTYPE_RPZ(client) \
|
||||
((client)->query.recursions[RECTYPE_RPZ].handle)
|
||||
#define HANDLE_RECTYPE_HOOK(client) \
|
||||
((client)->query.recursions[RECTYPE_HOOK].handle)
|
||||
|
||||
/*%
|
||||
* Helper macros for accessing dns_fetch_t pointers for a specific recursion a
|
||||
@@ -70,6 +73,8 @@ typedef enum {
|
||||
((client)->query.recursions[RECTYPE_PREFETCH].fetch)
|
||||
#define FETCH_RECTYPE_RPZ(client) \
|
||||
((client)->query.recursions[RECTYPE_RPZ].fetch)
|
||||
#define FETCH_RECTYPE_HOOK(client) \
|
||||
((client)->query.recursions[RECTYPE_HOOK].fetch)
|
||||
|
||||
/*%
|
||||
* nameserver recursion parameters, to uniquely identify a recursion
|
||||
|
@@ -6693,12 +6693,11 @@ query_hookresume(isc_task_t *task, isc_event_t *event) {
|
||||
UNLOCK(&client->manager->reclock);
|
||||
|
||||
/*
|
||||
* This event is running under a client task, so it's safe to detach
|
||||
* the fetch handle. And it should be done before resuming query
|
||||
* processing below, since that may trigger another recursion or
|
||||
* asynchronous hook event.
|
||||
* The fetch handle should be detached before resuming query processing
|
||||
* below, since that may trigger another recursion or asynchronous hook
|
||||
* event.
|
||||
*/
|
||||
isc_nmhandle_detach(&client->fetchhandle);
|
||||
isc_nmhandle_detach(&HANDLE_RECTYPE_HOOK(client));
|
||||
|
||||
client->state = NS_CLIENTSTATE_WORKING;
|
||||
|
||||
@@ -6814,7 +6813,7 @@ ns_query_hookasync(query_ctx_t *qctx, ns_query_starthookasync_t runasync,
|
||||
|
||||
REQUIRE(NS_CLIENT_VALID(client));
|
||||
REQUIRE(client->query.hookactx == NULL);
|
||||
REQUIRE(client->query.fetch == NULL);
|
||||
REQUIRE(FETCH_RECTYPE_NORMAL(client) == NULL);
|
||||
|
||||
result = check_recursionquota(client);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
@@ -6837,12 +6836,11 @@ ns_query_hookasync(query_ctx_t *qctx, ns_query_starthookasync_t runasync,
|
||||
* attribute won't be checked anywhere.
|
||||
*
|
||||
* Hook-based asynchronous processing cannot coincide with normal
|
||||
* recursion, so we can safely use fetchhandle here. Unlike in
|
||||
* ns_query_recurse(), we attach to the handle only if 'runasync'
|
||||
* succeeds. It should be safe since we're either in the client
|
||||
* task or pausing it.
|
||||
* recursion. Unlike in ns_query_recurse(), we attach to the handle
|
||||
* only if 'runasync' succeeds. It should be safe since we're either in
|
||||
* the client task or pausing it.
|
||||
*/
|
||||
isc_nmhandle_attach(client->handle, &client->fetchhandle);
|
||||
isc_nmhandle_attach(client->handle, &HANDLE_RECTYPE_HOOK(client));
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
cleanup:
|
||||
|
@@ -709,11 +709,11 @@ hook_async_common(void *arg, void *data, isc_result_t *resultp,
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* Resume from the completion of async event.
|
||||
* fetchhandle should have been detached so that we can start
|
||||
* another async event or DNS recursive resolution.
|
||||
* Resume from the completion of async event. The fetch handle
|
||||
* should have been detached so that we can start another async
|
||||
* event or DNS recursive resolution.
|
||||
*/
|
||||
INSIST(qctx->client->fetchhandle == NULL);
|
||||
INSIST(HANDLE_RECTYPE_HOOK(qctx->client) == NULL);
|
||||
asdata->async = false;
|
||||
switch (hookpoint) {
|
||||
case NS_QUERY_GOT_ANSWER_BEGIN:
|
||||
|
Reference in New Issue
Block a user