From: Ondřej Surý Date: Wed, 5 Aug 2026 14:26:13 +0000 (+0200) Subject: Do not attach nodep in sdlz_find() and builtin_find() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0358108db6a86bd918425390398bc3d8d5e2e6bb;p=thirdparty%2Fbind9.git Do not attach nodep in sdlz_find() and builtin_find() As a consequence of the simplification of the dns_db_find() API, we can avoid attaching the node in sdlz_find() and builtin_find(). The local node reference is only needed while assembling the answer and can be released before the function returns. --- diff --git a/bin/named/builtin.c b/bin/named/builtin.c index c0e159cd625..49defd05ad6 100644 --- a/bin/named/builtin.c +++ b/bin/named/builtin.c @@ -855,12 +855,13 @@ findnode(dns_db_t *db, const dns_name_t *name, bool create, } static isc_result_t -find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version, - dns_rdatatype_t type, unsigned int options, isc_stdtime_t now, - dns_dbnode_t **nodep, dns_name_t *foundname, - dns_clientinfomethods_t *methods ISC_ATTR_UNUSED, - dns_clientinfo_t *clientinfo ISC_ATTR_UNUSED, dns_rdataset_t *rdataset, - dns_rdataset_t *sigrdataset DNS__DB_FLARG) { +builtin_find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version, + dns_rdatatype_t type, unsigned int options, isc_stdtime_t now, + dns_dbnode_t **nodep ISC_ATTR_UNUSED, dns_name_t *foundname, + dns_clientinfomethods_t *methods ISC_ATTR_UNUSED, + dns_clientinfo_t *clientinfo ISC_ATTR_UNUSED, + dns_rdataset_t *rdataset, + dns_rdataset_t *sigrdataset DNS__DB_FLARG) { bdb_t *bdb = (bdb_t *)db; isc_result_t result; dns_dbnode_t *node = NULL; @@ -871,7 +872,6 @@ find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version, bool dns64; REQUIRE(VALID_BDB(bdb)); - REQUIRE(nodep == NULL || *nodep == NULL); REQUIRE(version == NULL || version == (dns_dbversion_t *)&dummy); if (!dns_name_issubdomain(name, &db->origin)) { @@ -1005,9 +1005,7 @@ find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version, dns_name_copy(xname, foundname); } - if (nodep != NULL) { - *nodep = node; - } else if (node != NULL) { + if (node != NULL) { bdbnode_detachnode(&node DNS__DB_FLARG_PASS); } @@ -1098,7 +1096,7 @@ static dns_dbmethods_t bdb_methods = { .findrdataset = findrdataset, .allrdatasets = allrdatasets, .findnode = findnode, - .find = find, + .find = builtin_find, }; static isc_result_t diff --git a/lib/dns/sdlz.c b/lib/dns/sdlz.c index 198967f738b..cdd2f438c5a 100644 --- a/lib/dns/sdlz.c +++ b/lib/dns/sdlz.c @@ -763,11 +763,12 @@ findrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version, } static isc_result_t -find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version, - dns_rdatatype_t type, unsigned int options, isc_stdtime_t now, - dns_dbnode_t **nodep, dns_name_t *foundname, - dns_clientinfomethods_t *methods, dns_clientinfo_t *clientinfo, - dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset DNS__DB_FLARG) { +sdlz_find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version, + dns_rdatatype_t type, unsigned int options, isc_stdtime_t now, + dns_dbnode_t **nodep ISC_ATTR_UNUSED, dns_name_t *foundname, + dns_clientinfomethods_t *methods, dns_clientinfo_t *clientinfo, + dns_rdataset_t *rdataset, + dns_rdataset_t *sigrdataset DNS__DB_FLARG) { dns_sdlz_db_t *sdlz = (dns_sdlz_db_t *)db; dns_dbnode_t *node = NULL; dns_fixedname_t fname; @@ -778,7 +779,6 @@ find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version, unsigned int i; REQUIRE(VALID_SDLZDB(sdlz)); - REQUIRE(nodep == NULL || *nodep == NULL); REQUIRE(version == NULL || version == (void *)&sdlz->dummy_version || version == sdlz->future_version); @@ -926,9 +926,7 @@ find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version, } } - if (nodep != NULL) { - *nodep = node; - } else if (node != NULL) { + if (node != NULL) { sdlznode_detachnode(&node DNS__DB_FLARG_PASS); } @@ -1098,7 +1096,7 @@ static dns_dbmethods_t sdlzdb_methods = { .attachversion = attachversion, .closeversion = closeversion, .findnode = findnode, - .find = find, + .find = sdlz_find, .createiterator = createiterator, .findrdataset = findrdataset, .allrdatasets = allrdatasets,