From 9882a6ef904b0405d0e048407db79e91c078ce22 Mon Sep 17 00:00:00 2001 From: Tony Finch Date: Thu, 27 Apr 2023 12:47:03 +0100 Subject: [PATCH] The zone table no longer depends on the loop manager This reverts some of the changes in commit b171cacf4f0123ba because now it isn't necessary to pass the loopmgr around. --- bin/delv/delv.c | 3 +-- bin/named/server.c | 3 +-- bin/tests/system/pipelined/pipequeries.c | 2 +- bin/tools/mdig.c | 2 +- fuzz/dns_message_checksig.c | 3 +-- lib/dns/client.c | 3 +-- lib/dns/include/dns/view.h | 4 ++-- lib/dns/include/dns/zt.h | 3 +-- lib/dns/view.c | 5 ++--- lib/dns/zt.c | 12 ++++-------- tests/bench/qpmulti.c | 3 +-- tests/dns/qpmulti_test.c | 2 +- tests/libtest/dns.c | 2 +- 13 files changed, 18 insertions(+), 29 deletions(-) diff --git a/bin/delv/delv.c b/bin/delv/delv.c index fc10c7137c..6ae6af9183 100644 --- a/bin/delv/delv.c +++ b/bin/delv/delv.c @@ -2147,8 +2147,7 @@ run_server(void *arg) { CHECK(ns_interfacemgr_create(mctx, sctx, loopmgr, netmgr, dispatchmgr, NULL, false, &interfacemgr)); - CHECK(dns_view_create(mctx, loopmgr, dns_rdataclass_in, "_default", - &view)); + CHECK(dns_view_create(mctx, dns_rdataclass_in, "_default", &view)); CHECK(dns_cache_create(loopmgr, dns_rdataclass_in, "", &cache)); dns_view_setcache(view, cache, false); dns_cache_detach(&cache); diff --git a/bin/named/server.c b/bin/named/server.c index a13c9c7a4d..d38ecffd01 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -6437,8 +6437,7 @@ create_view(const cfg_obj_t *vconfig, dns_viewlist_t *viewlist, } INSIST(view == NULL); - result = dns_view_create(named_g_mctx, named_g_loopmgr, viewclass, - viewname, &view); + result = dns_view_create(named_g_mctx, viewclass, viewname, &view); if (result != ISC_R_SUCCESS) { return (result); } diff --git a/bin/tests/system/pipelined/pipequeries.c b/bin/tests/system/pipelined/pipequeries.c index 5569ad318d..805e3c5344 100644 --- a/bin/tests/system/pipelined/pipequeries.c +++ b/bin/tests/system/pipelined/pipequeries.c @@ -256,7 +256,7 @@ main(int argc, char *argv[]) { RUNCHECK(dns_requestmgr_create(mctx, dispatchmgr, dispatchv4, NULL, &requestmgr)); - RUNCHECK(dns_view_create(mctx, loopmgr, 0, "_test", &view)); + RUNCHECK(dns_view_create(mctx, 0, "_test", &view)); isc_loopmgr_setup(loopmgr, sendqueries, NULL); isc_loopmgr_run(loopmgr); diff --git a/bin/tools/mdig.c b/bin/tools/mdig.c index 4193f06912..7a366c0e85 100644 --- a/bin/tools/mdig.c +++ b/bin/tools/mdig.c @@ -2141,7 +2141,7 @@ main(int argc, char *argv[]) { mctx, dispatchmgr, have_ipv4 ? dispatchvx : NULL, have_ipv6 ? dispatchvx : NULL, &requestmgr)); - RUNCHECK(dns_view_create(mctx, loopmgr, 0, "_mdig", &view)); + RUNCHECK(dns_view_create(mctx, 0, "_mdig", &view)); query = ISC_LIST_HEAD(queries); isc_loopmgr_setup(loopmgr, sendqueries, query); diff --git a/fuzz/dns_message_checksig.c b/fuzz/dns_message_checksig.c index c27bfebe8b..a4b9dd15ab 100644 --- a/fuzz/dns_message_checksig.c +++ b/fuzz/dns_message_checksig.c @@ -236,8 +236,7 @@ LLVMFuzzerInitialize(int *argc ISC_ATTR_UNUSED, char ***argv ISC_ATTR_UNUSED) { isc_loopmgr_create(mctx, 1, &loopmgr); - result = dns_view_create(mctx, loopmgr, dns_rdataclass_in, "view", - &view); + result = dns_view_create(mctx, dns_rdataclass_in, "view", &view); if (result != ISC_R_SUCCESS) { fprintf(stderr, "dns_view_create failed: %s\n", isc_result_totext(result)); diff --git a/lib/dns/client.c b/lib/dns/client.c index 5a3c0fadda..579b9c3aab 100644 --- a/lib/dns/client.c +++ b/lib/dns/client.c @@ -206,8 +206,7 @@ createview(isc_mem_t *mctx, dns_rdataclass_t rdclass, isc_loopmgr_t *loopmgr, isc_result_t result; dns_view_t *view = NULL; - result = dns_view_create(mctx, loopmgr, rdclass, DNS_CLIENTVIEW_NAME, - &view); + result = dns_view_create(mctx, rdclass, DNS_CLIENTVIEW_NAME, &view); if (result != ISC_R_SUCCESS) { return (result); } diff --git a/lib/dns/include/dns/view.h b/lib/dns/include/dns/view.h index b72a3dd44f..e801b3a30f 100644 --- a/lib/dns/include/dns/view.h +++ b/lib/dns/include/dns/view.h @@ -259,8 +259,8 @@ struct dns_view { #endif /* HAVE_LMDB */ isc_result_t -dns_view_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr, - dns_rdataclass_t rdclass, const char *name, dns_view_t **viewp); +dns_view_create(isc_mem_t *mctx, dns_rdataclass_t rdclass, const char *name, + dns_view_t **viewp); /*%< * Create a view. * diff --git a/lib/dns/include/dns/zt.h b/lib/dns/include/dns/zt.h index 1118d06428..3ed74911c2 100644 --- a/lib/dns/include/dns/zt.h +++ b/lib/dns/include/dns/zt.h @@ -34,8 +34,7 @@ typedef isc_result_t dns_zt_callback_t(void *arg); void -dns_zt_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr, dns_view_t *view, - dns_zt_t **ztp); +dns_zt_create(isc_mem_t *mctx, dns_view_t *view, dns_zt_t **ztp); /*%< * Creates a new zone table for a view. * diff --git a/lib/dns/view.c b/lib/dns/view.c index 5f58142627..ee2a5c9a06 100644 --- a/lib/dns/view.c +++ b/lib/dns/view.c @@ -79,8 +79,7 @@ #define DEFAULT_EDNS_BUFSIZE 1232 isc_result_t -dns_view_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr, - dns_rdataclass_t rdclass, const char *name, +dns_view_create(isc_mem_t *mctx, dns_rdataclass_t rdclass, const char *name, dns_view_t **viewp) { dns_view_t *view = NULL; isc_result_t result; @@ -135,7 +134,7 @@ dns_view_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr, isc_rwlock_init(&view->sfd_lock); view->zonetable = NULL; - dns_zt_create(mctx, loopmgr, view, &view->zonetable); + dns_zt_create(mctx, view, &view->zonetable); result = dns_fwdtable_create(mctx, &view->fwdtable); if (result != ISC_R_SUCCESS) { diff --git a/lib/dns/zt.c b/lib/dns/zt.c index cf91f7285b..01bed3c290 100644 --- a/lib/dns/zt.c +++ b/lib/dns/zt.c @@ -94,15 +94,14 @@ static dns_qpmethods_t ztqpmethods = { }; void -dns_zt_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr, dns_view_t *view, - dns_zt_t **ztp) { +dns_zt_create(isc_mem_t *mctx, dns_view_t *view, dns_zt_t **ztp) { dns_qpmulti_t *multi = NULL; dns_zt_t *zt = NULL; REQUIRE(ztp != NULL && *ztp == NULL); REQUIRE(view != NULL); - dns_qpmulti_create(mctx, loopmgr, &ztqpmethods, view, &multi); + dns_qpmulti_create(mctx, &ztqpmethods, view, &multi); zt = isc_mem_get(mctx, sizeof(*zt)); *zt = (dns_zt_t){ @@ -177,11 +176,8 @@ dns_zt_find(dns_zt_t *zt, const dns_name_t *name, dns_ztfind_t options, REQUIRE(VALID_ZT(zt)); REQUIRE(exactopts != exactmask); - if (isc_tid() == ISC_TID_UNKNOWN) { - dns_qpmulti_lockedread(zt->multi, &qpr); - } else { - dns_qpmulti_query(zt->multi, &qpr); - } + dns_qpmulti_query(zt->multi, &qpr); + if (exactopts == DNS_ZTFIND_EXACT) { result = dns_qp_getname(&qpr, name, &pval, &ival); } else if (exactopts == DNS_ZTFIND_NOEXACT) { diff --git a/tests/bench/qpmulti.c b/tests/bench/qpmulti.c index 7034ac983f..93b98a0b6a 100644 --- a/tests/bench/qpmulti.c +++ b/tests/bench/qpmulti.c @@ -380,8 +380,7 @@ load_multi(struct bench_state *bctx) { size_t count = 0; uint64_t start; - dns_qpmulti_create(bctx->mctx, bctx->loopmgr, &item_methods, NULL, - &bctx->multi); + dns_qpmulti_create(bctx->mctx, &item_methods, NULL, &bctx->multi); /* initial contents of the trie */ start = isc_time_monotonic(); diff --git a/tests/dns/qpmulti_test.c b/tests/dns/qpmulti_test.c index 16e5350dec..d5a5b91d0b 100644 --- a/tests/dns/qpmulti_test.c +++ b/tests/dns/qpmulti_test.c @@ -367,7 +367,7 @@ many_transactions(void *arg) { UNUSED(arg); dns_qpmulti_t *qpm = NULL; - dns_qpmulti_create(mctx, loopmgr, &test_methods, NULL, &qpm); + dns_qpmulti_create(mctx, &test_methods, NULL, &qpm); qpm->writer.write_protect = true; for (size_t n = 0; n < TRANSACTION_COUNT; n++) { diff --git a/tests/libtest/dns.c b/tests/libtest/dns.c index b093b88c43..d398c5c954 100644 --- a/tests/libtest/dns.c +++ b/tests/libtest/dns.c @@ -64,7 +64,7 @@ dns_test_makeview(const char *name, bool with_cache, dns_view_t **viewp) { dns_view_t *view = NULL; dns_cache_t *cache = NULL; - result = dns_view_create(mctx, loopmgr, dns_rdataclass_in, name, &view); + result = dns_view_create(mctx, dns_rdataclass_in, name, &view); if (result != ISC_R_SUCCESS) { return (result); }