static ns_hookresult_t
filter_query_done_send(void *arg, void *cbdata, isc_result_t *resp);
static ns_hookresult_t
-filter_qctx_destroy(void *arg, void *cbdata, isc_result_t *resp);
+filter_freeclientstate(void *arg, void *cbdata, isc_result_t *resp);
/*%
* Register the functions to be called at each hook point in 'hooktable', using
.action_data = inst,
};
- const ns_hook_t filter_destroy = {
- .action = filter_qctx_destroy,
+ const ns_hook_t filter_reset = {
+ .action = filter_freeclientstate,
.action_data = inst,
};
- ns_hook_add(hooktable, mctx, NS_QUERY_QCTX_INITIALIZED, &filter_init);
+ ns_hook_add(hooktable, mctx, NS_QUERY_SETUP, &filter_init);
ns_hook_add(hooktable, mctx, NS_QUERY_AUTHZONE_ATTACHED, &filter_init);
ns_hook_add(hooktable, mctx, NS_QUERY_RESPOND_BEGIN, &filter_respbegin);
ns_hook_add(hooktable, mctx, NS_QUERY_RESPOND_ANY_FOUND,
ns_hook_add(hooktable, mctx, NS_QUERY_PREP_RESPONSE_BEGIN,
&filter_prepresp);
ns_hook_add(hooktable, mctx, NS_QUERY_DONE_SEND, &filter_donesend);
- ns_hook_add(hooktable, mctx, NS_QUERY_QCTX_DESTROYED, &filter_destroy);
+ ns_hook_add(hooktable, mctx, NS_QUERY_RESET, &filter_reset);
}
/**
* from hash table and return it to the memory pool.
*/
static ns_hookresult_t
-filter_qctx_destroy(void *arg, void *cbdata, isc_result_t *resp) {
+filter_freeclientstate(void *arg, void *cbdata, isc_result_t *resp) {
query_ctx_t *qctx = (query_ctx_t *)arg;
filter_instance_t *inst = (filter_instance_t *)cbdata;
*resp = ISC_R_UNSET;
-
- if (!qctx->detach_client) {
- return NS_HOOK_CONTINUE;
- }
-
client_state_destroy(qctx, inst);
return NS_HOOK_CONTINUE;
static ns_hookresult_t
filter_query_done_send(void *arg, void *cbdata, isc_result_t *resp);
static ns_hookresult_t
-filter_qctx_destroy(void *arg, void *cbdata, isc_result_t *resp);
+filter_freeclientstate(void *arg, void *cbdata, isc_result_t *resp);
/*%
* Register the functions to be called at each hook point in 'hooktable', using
.action_data = inst,
};
- const ns_hook_t filter_destroy = {
- .action = filter_qctx_destroy,
+ const ns_hook_t filter_reset = {
+ .action = filter_freeclientstate,
.action_data = inst,
};
- ns_hook_add(hooktable, mctx, NS_QUERY_QCTX_INITIALIZED, &filter_init);
+ ns_hook_add(hooktable, mctx, NS_QUERY_SETUP, &filter_init);
ns_hook_add(hooktable, mctx, NS_QUERY_AUTHZONE_ATTACHED, &filter_init);
ns_hook_add(hooktable, mctx, NS_QUERY_RESPOND_BEGIN, &filter_respbegin);
ns_hook_add(hooktable, mctx, NS_QUERY_RESPOND_ANY_FOUND,
ns_hook_add(hooktable, mctx, NS_QUERY_PREP_RESPONSE_BEGIN,
&filter_prepresp);
ns_hook_add(hooktable, mctx, NS_QUERY_DONE_SEND, &filter_donesend);
- ns_hook_add(hooktable, mctx, NS_QUERY_QCTX_DESTROYED, &filter_destroy);
+ ns_hook_add(hooktable, mctx, NS_QUERY_RESET, &filter_reset);
}
/**
* from hash table and return it to the memory pool.
*/
static ns_hookresult_t
-filter_qctx_destroy(void *arg, void *cbdata, isc_result_t *resp) {
+filter_freeclientstate(void *arg, void *cbdata, isc_result_t *resp) {
query_ctx_t *qctx = (query_ctx_t *)arg;
filter_instance_t *inst = (filter_instance_t *)cbdata;
*resp = ISC_R_UNSET;
-
- if (!qctx->detach_client) {
- return NS_HOOK_CONTINUE;
- }
-
client_state_destroy(qctx, inst);
return NS_HOOK_CONTINUE;
* Forward declarations of functions referenced in install_hooks().
*/
static ns_hookresult_t
-async_qctx_initialize(void *arg, void *cbdata, isc_result_t *resp);
+async_query_setup(void *arg, void *cbdata, isc_result_t *resp);
static ns_hookresult_t
async_query_done_begin(void *arg, void *cbdata, isc_result_t *resp);
static ns_hookresult_t
-async_qctx_destroy(void *arg, void *cbdata, isc_result_t *resp);
+async_query_reset(void *arg, void *cbdata, isc_result_t *resp);
/*%
* Register the functions to be called at each hook point in 'hooktable', using
static void
install_hooks(ns_hooktable_t *hooktable, isc_mem_t *mctx,
async_instance_t *inst) {
- const ns_hook_t async_init = {
- .action = async_qctx_initialize,
+ const ns_hook_t async_setup = {
+ .action = async_query_setup,
.action_data = inst,
};
const ns_hook_t async_donebegin = {
.action = async_query_done_begin,
.action_data = inst,
};
- const ns_hook_t async_destroy = {
- .action = async_qctx_destroy,
+ const ns_hook_t async_reset = {
+ .action = async_query_reset,
.action_data = inst,
};
- ns_hook_add(hooktable, mctx, NS_QUERY_QCTX_INITIALIZED, &async_init);
+ ns_hook_add(hooktable, mctx, NS_QUERY_SETUP, &async_setup);
ns_hook_add(hooktable, mctx, NS_QUERY_DONE_BEGIN, &async_donebegin);
- ns_hook_add(hooktable, mctx, NS_QUERY_QCTX_DESTROYED, &async_destroy);
+ ns_hook_add(hooktable, mctx, NS_QUERY_RESET, &async_reset);
}
static void
}
static ns_hookresult_t
-async_qctx_initialize(void *arg, void *cbdata, isc_result_t *resp) {
+async_query_setup(void *arg, void *cbdata, isc_result_t *resp) {
query_ctx_t *qctx = (query_ctx_t *)arg;
async_instance_t *inst = (async_instance_t *)cbdata;
state_t *state = NULL;
- logmsg("qctx init hook");
+ logmsg("query setup hook");
*resp = ISC_R_UNSET;
state = client_state_get(qctx, inst);
}
static ns_hookresult_t
-async_qctx_destroy(void *arg, void *cbdata, isc_result_t *resp) {
+async_query_reset(void *arg, void *cbdata, isc_result_t *resp) {
query_ctx_t *qctx = (query_ctx_t *)arg;
async_instance_t *inst = (async_instance_t *)cbdata;
- logmsg("qctx destroy hook");
+ logmsg("query reset hook");
*resp = ISC_R_UNSET;
-
- if (!qctx->detach_client) {
- return NS_HOOK_CONTINUE;
- }
-
client_state_destroy(qctx, inst);
return NS_HOOK_CONTINUE;
return hook_async_common(arg, data, resultp, NS_QUERY_DONE_BEGIN);
}
-/*
- * hook on destroying actx. Can't be used for async event, but we use this
- * to remember the qctx at that point.
- */
-static ns_hookresult_t
-ns_test_qctx_destroy_hook(void *arg, void *data, isc_result_t *resultp) {
- query_ctx_t *qctx = arg;
- hookasync_data_t *asdata = data;
-
- asdata->qctx = *qctx; /* remember passed ctx for inspection */
- *resultp = ISC_R_UNSET;
- return NS_HOOK_CONTINUE;
-}
-
static void
run_hookasync_test(const ns__query_hookasync_test_params_t *test) {
query_ctx_t *qctx = NULL;
.action = test->action,
.action_data = &asdata,
};
- const ns_hook_t destroyhook = {
- .action = ns_test_qctx_destroy_hook,
- .action_data = &asdata,
- };
isc_statscounter_t srvfail_cnt;
bool expect_servfail = false;
ns_hook_add(ns__hook_table, isc_g_mctx, test->hookpoint2,
&testhook);
}
- ns_hook_add(ns__hook_table, isc_g_mctx, NS_QUERY_QCTX_DESTROYED,
- &destroyhook);
{
const ns_test_qctx_create_params_t qctx_params = {
/*
* Confirm SERVFAIL has been sent if it was expected.
- * Also, the last-generated qctx should have detach_client being true.
*/
if (expect_servfail) {
INSIST(ns_stats_get_counter(
qctx->client->manager->sctx->nsstats,
ns_statscounter_servfail) == srvfail_cnt + 1);
- if (test->do_cancel) {
- /* qctx was created on resume and copied in hook */
- INSIST(asdata.qctx.detach_client);
- } else {
- INSIST(qctx->detach_client);
- }
}
/*