From: Michal Nowak Date: Mon, 12 Oct 2020 16:20:58 +0000 (+0200) Subject: Drop unused dbtable code X-Git-Tag: v9.17.7~48^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e67737aa758b86d4a7e245e2924b85bf7473d6c2;p=thirdparty%2Fbind9.git Drop unused dbtable code --- diff --git a/lib/dns/Makefile.am b/lib/dns/Makefile.am index 73e6bc2f738..f53debaccf9 100644 --- a/lib/dns/Makefile.am +++ b/lib/dns/Makefile.am @@ -64,7 +64,6 @@ libdns_la_HEADERS = \ include/dns/compress.h \ include/dns/db.h \ include/dns/dbiterator.h \ - include/dns/dbtable.h \ include/dns/diff.h \ include/dns/dispatch.h \ include/dns/dlz.h \ @@ -168,7 +167,6 @@ libdns_la_SOURCES = \ compress.c \ db.c \ dbiterator.c \ - dbtable.c \ diff.c \ dispatch.c \ dlz.c \ diff --git a/lib/dns/dbtable.c b/lib/dns/dbtable.c deleted file mode 100644 index e237fd63336..00000000000 --- a/lib/dns/dbtable.c +++ /dev/null @@ -1,254 +0,0 @@ -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, you can obtain one at https://mozilla.org/MPL/2.0/. - * - * See the COPYRIGHT file distributed with this work for additional - * information regarding copyright ownership. - */ - -#include - -#include -#include -#include - -#include -#include -#include -#include - -struct dns_dbtable { - /* Unlocked. */ - unsigned int magic; - isc_mem_t *mctx; - dns_rdataclass_t rdclass; - isc_rwlock_t tree_lock; - /* Protected by atomics */ - isc_refcount_t references; - /* Locked by tree_lock. */ - dns_rbt_t *rbt; - dns_db_t *default_db; -}; - -#define DBTABLE_MAGIC ISC_MAGIC('D', 'B', '-', '-') -#define VALID_DBTABLE(dbtable) ISC_MAGIC_VALID(dbtable, DBTABLE_MAGIC) - -static void -dbdetach(void *data, void *arg) { - dns_db_t *db = data; - - UNUSED(arg); - - dns_db_detach(&db); -} - -isc_result_t -dns_dbtable_create(isc_mem_t *mctx, dns_rdataclass_t rdclass, - dns_dbtable_t **dbtablep) { - dns_dbtable_t *dbtable; - isc_result_t result; - - REQUIRE(mctx != NULL); - REQUIRE(dbtablep != NULL && *dbtablep == NULL); - - dbtable = isc_mem_get(mctx, sizeof(*dbtable)); - - dbtable->rbt = NULL; - result = dns_rbt_create(mctx, dbdetach, NULL, &dbtable->rbt); - if (result != ISC_R_SUCCESS) { - goto clean1; - } - - result = isc_rwlock_init(&dbtable->tree_lock, 0, 0); - if (result != ISC_R_SUCCESS) { - goto clean3; - } - - dbtable->default_db = NULL; - dbtable->mctx = NULL; - isc_mem_attach(mctx, &dbtable->mctx); - dbtable->rdclass = rdclass; - dbtable->magic = DBTABLE_MAGIC; - isc_refcount_init(&dbtable->references, 1); - - *dbtablep = dbtable; - - return (ISC_R_SUCCESS); - -clean3: - dns_rbt_destroy(&dbtable->rbt); - -clean1: - isc_mem_putanddetach(&mctx, dbtable, sizeof(*dbtable)); - - return (result); -} - -static inline void -dbtable_free(dns_dbtable_t *dbtable) { - /* - * Caller must ensure that it is safe to call. - */ - - RWLOCK(&dbtable->tree_lock, isc_rwlocktype_write); - - if (dbtable->default_db != NULL) { - dns_db_detach(&dbtable->default_db); - } - - dns_rbt_destroy(&dbtable->rbt); - - RWUNLOCK(&dbtable->tree_lock, isc_rwlocktype_write); - - isc_rwlock_destroy(&dbtable->tree_lock); - - dbtable->magic = 0; - - isc_mem_putanddetach(&dbtable->mctx, dbtable, sizeof(*dbtable)); -} - -void -dns_dbtable_attach(dns_dbtable_t *source, dns_dbtable_t **targetp) { - REQUIRE(VALID_DBTABLE(source)); - REQUIRE(targetp != NULL && *targetp == NULL); - - isc_refcount_increment(&source->references); - - *targetp = source; -} - -void -dns_dbtable_detach(dns_dbtable_t **dbtablep) { - dns_dbtable_t *dbtable; - - REQUIRE(dbtablep != NULL); - dbtable = *dbtablep; - *dbtablep = NULL; - REQUIRE(VALID_DBTABLE(dbtable)); - - if (isc_refcount_decrement(&dbtable->references) == 1) { - dbtable_free(dbtable); - } -} - -isc_result_t -dns_dbtable_add(dns_dbtable_t *dbtable, dns_db_t *db) { - isc_result_t result; - dns_db_t *dbclone; - - REQUIRE(VALID_DBTABLE(dbtable)); - REQUIRE(dns_db_class(db) == dbtable->rdclass); - - dbclone = NULL; - dns_db_attach(db, &dbclone); - - RWLOCK(&dbtable->tree_lock, isc_rwlocktype_write); - result = dns_rbt_addname(dbtable->rbt, dns_db_origin(dbclone), dbclone); - RWUNLOCK(&dbtable->tree_lock, isc_rwlocktype_write); - - return (result); -} - -void -dns_dbtable_remove(dns_dbtable_t *dbtable, dns_db_t *db) { - dns_db_t *stored_data = NULL; - isc_result_t result; - dns_name_t *name; - - REQUIRE(VALID_DBTABLE(dbtable)); - - name = dns_db_origin(db); - - /* - * There is a requirement that the association of name with db - * be verified. With the current rbt.c this is expensive to do, - * because effectively two find operations are being done, but - * deletion is relatively infrequent. - * XXXDCL ... this could be cheaper now with dns_rbt_deletenode. - */ - - RWLOCK(&dbtable->tree_lock, isc_rwlocktype_write); - - result = dns_rbt_findname(dbtable->rbt, name, 0, NULL, - (void **)(void *)&stored_data); - - if (result == ISC_R_SUCCESS) { - INSIST(stored_data == db); - - (void)dns_rbt_deletename(dbtable->rbt, name, false); - } - - RWUNLOCK(&dbtable->tree_lock, isc_rwlocktype_write); -} - -void -dns_dbtable_adddefault(dns_dbtable_t *dbtable, dns_db_t *db) { - REQUIRE(VALID_DBTABLE(dbtable)); - REQUIRE(dbtable->default_db == NULL); - REQUIRE(dns_name_compare(dns_db_origin(db), dns_rootname) == 0); - - RWLOCK(&dbtable->tree_lock, isc_rwlocktype_write); - - dbtable->default_db = NULL; - dns_db_attach(db, &dbtable->default_db); - - RWUNLOCK(&dbtable->tree_lock, isc_rwlocktype_write); -} - -void -dns_dbtable_getdefault(dns_dbtable_t *dbtable, dns_db_t **dbp) { - REQUIRE(VALID_DBTABLE(dbtable)); - REQUIRE(dbp != NULL && *dbp == NULL); - - RWLOCK(&dbtable->tree_lock, isc_rwlocktype_read); - - dns_db_attach(dbtable->default_db, dbp); - - RWUNLOCK(&dbtable->tree_lock, isc_rwlocktype_read); -} - -void -dns_dbtable_removedefault(dns_dbtable_t *dbtable) { - REQUIRE(VALID_DBTABLE(dbtable)); - - RWLOCK(&dbtable->tree_lock, isc_rwlocktype_write); - - dns_db_detach(&dbtable->default_db); - - RWUNLOCK(&dbtable->tree_lock, isc_rwlocktype_write); -} - -isc_result_t -dns_dbtable_find(dns_dbtable_t *dbtable, const dns_name_t *name, - unsigned int options, dns_db_t **dbp) { - dns_db_t *stored_data = NULL; - isc_result_t result; - unsigned int rbtoptions = 0; - - REQUIRE(dbp != NULL && *dbp == NULL); - - if ((options & DNS_DBTABLEFIND_NOEXACT) != 0) { - rbtoptions |= DNS_RBTFIND_NOEXACT; - } - - RWLOCK(&dbtable->tree_lock, isc_rwlocktype_read); - - result = dns_rbt_findname(dbtable->rbt, name, rbtoptions, NULL, - (void **)(void *)&stored_data); - - if (result == ISC_R_SUCCESS || result == DNS_R_PARTIALMATCH) { - dns_db_attach(stored_data, dbp); - } else if (dbtable->default_db != NULL) { - dns_db_attach(dbtable->default_db, dbp); - result = DNS_R_PARTIALMATCH; - } else { - result = ISC_R_NOTFOUND; - } - - RWUNLOCK(&dbtable->tree_lock, isc_rwlocktype_read); - - return (result); -} diff --git a/lib/dns/include/dns/dbtable.h b/lib/dns/include/dns/dbtable.h deleted file mode 100644 index 3b78c412ef7..00000000000 --- a/lib/dns/include/dns/dbtable.h +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, you can obtain one at https://mozilla.org/MPL/2.0/. - * - * See the COPYRIGHT file distributed with this work for additional - * information regarding copyright ownership. - */ - -#ifndef DNS_DBTABLE_H -#define DNS_DBTABLE_H 1 - -/***** -***** Module Info -*****/ - -/*! \file dns/dbtable.h - * \brief - * DNS DB Tables - * - * XXX TBS XXX - * - * MP: - *\li The module ensures appropriate synchronization of data structures it - * creates and manipulates. - * - * Reliability: - *\li No anticipated impact. - * - * Resources: - *\li None. - * - * Security: - *\li No anticipated impact. - * - * Standards: - *\li None. - */ - -#include - -#include - -#define DNS_DBTABLEFIND_NOEXACT 0x01 - -ISC_LANG_BEGINDECLS - -isc_result_t -dns_dbtable_create(isc_mem_t *mctx, dns_rdataclass_t rdclass, - dns_dbtable_t **dbtablep); -/*%< - * Make a new dbtable of class 'rdclass' - * - * Requires: - *\li mctx != NULL - * \li dbtablep != NULL && *dptablep == NULL - *\li 'rdclass' is a valid class - * - * Returns: - *\li #ISC_R_SUCCESS - *\li #ISC_R_NOMEMORY - *\li #ISC_R_UNEXPECTED - */ - -void -dns_dbtable_attach(dns_dbtable_t *source, dns_dbtable_t **targetp); -/*%< - * Attach '*targetp' to 'source'. - * - * Requires: - * - *\li 'source' is a valid dbtable. - * - *\li 'targetp' points to a NULL dns_dbtable_t *. - * - * Ensures: - * - *\li *targetp is attached to source. - */ - -void -dns_dbtable_detach(dns_dbtable_t **dbtablep); -/*%< - * Detach *dbtablep from its dbtable. - * - * Requires: - * - *\li '*dbtablep' points to a valid dbtable. - * - * Ensures: - * - *\li *dbtablep is NULL. - * - *\li If '*dbtablep' is the last reference to the dbtable, - * all resources used by the dbtable will be freed - */ - -isc_result_t -dns_dbtable_add(dns_dbtable_t *dbtable, dns_db_t *db); -/*%< - * Add 'db' to 'dbtable'. - * - * Requires: - *\li 'dbtable' is a valid dbtable. - * - *\li 'db' is a valid database with the same class as 'dbtable' - */ - -void -dns_dbtable_remove(dns_dbtable_t *dbtable, dns_db_t *db); -/*%< - * Remove 'db' from 'dbtable'. - * - * Requires: - *\li 'db' was previously added to 'dbtable'. - */ - -void -dns_dbtable_adddefault(dns_dbtable_t *dbtable, dns_db_t *db); -/*%< - * Use 'db' as the result of a dns_dbtable_find() if no better match is - * available. - */ - -void -dns_dbtable_getdefault(dns_dbtable_t *dbtable, dns_db_t **db); -/*%< - * Get the 'db' used as the result of a dns_dbtable_find() - * if no better match is available. - */ - -void -dns_dbtable_removedefault(dns_dbtable_t *dbtable); -/*%< - * Remove the default db from 'dbtable'. - */ - -isc_result_t -dns_dbtable_find(dns_dbtable_t *dbtable, const dns_name_t *name, - unsigned int options, dns_db_t **dbp); -/*%< - * Find the deepest match to 'name' in the dbtable, and return it - * - * Notes: - *\li If the DNS_DBTABLEFIND_NOEXACT option is set, the best partial - * match (if any) to 'name' will be returned. - * - * Returns: - * \li #ISC_R_SUCCESS on success - *\li something else: no default and match - */ - -ISC_LANG_ENDDECLS - -#endif /* DNS_DBTABLE_H */ diff --git a/lib/dns/include/dns/types.h b/lib/dns/include/dns/types.h index d918cf39cc2..2a08c31b5f4 100644 --- a/lib/dns/include/dns/types.h +++ b/lib/dns/include/dns/types.h @@ -57,7 +57,6 @@ typedef struct dns_dbiterator dns_dbiterator_t; typedef void dns_dbload_t; typedef void dns_dbnode_t; typedef struct dns_dbonupdatelistener dns_dbonupdatelistener_t; -typedef struct dns_dbtable dns_dbtable_t; typedef void dns_dbversion_t; typedef struct dns_dlzimplementation dns_dlzimplementation_t; typedef struct dns_dlzdb dns_dlzdb_t; diff --git a/lib/dns/win32/libdns.def.in b/lib/dns/win32/libdns.def.in index e446d4dc230..56061f76c0c 100644 --- a/lib/dns/win32/libdns.def.in +++ b/lib/dns/win32/libdns.def.in @@ -240,15 +240,6 @@ dns_dbiterator_pause dns_dbiterator_prev dns_dbiterator_seek dns_dbiterator_setcleanmode -dns_dbtable_add -dns_dbtable_adddefault -dns_dbtable_attach -dns_dbtable_create -dns_dbtable_detach -dns_dbtable_find -dns_dbtable_getdefault -dns_dbtable_remove -dns_dbtable_removedefault dns_decompress_edns dns_decompress_getmethods dns_decompress_init diff --git a/lib/dns/win32/libdns.vcxproj.filters.in b/lib/dns/win32/libdns.vcxproj.filters.in index 5ba61623f03..7469f7bced0 100644 --- a/lib/dns/win32/libdns.vcxproj.filters.in +++ b/lib/dns/win32/libdns.vcxproj.filters.in @@ -63,9 +63,6 @@ Library Source Files - - Library Source Files - Library Source Files @@ -380,9 +377,6 @@ Library Header Files - - Library Header Files - Library Header Files diff --git a/lib/dns/win32/libdns.vcxproj.in b/lib/dns/win32/libdns.vcxproj.in index 9af373e06c0..644e809c3ca 100644 --- a/lib/dns/win32/libdns.vcxproj.in +++ b/lib/dns/win32/libdns.vcxproj.in @@ -130,7 +130,6 @@ - @@ -246,7 +245,6 @@ - diff --git a/util/copyrights b/util/copyrights index 772ad87b860..16a47dfcb24 100644 --- a/util/copyrights +++ b/util/copyrights @@ -1279,7 +1279,6 @@ ./lib/dns/compress.c C 1999,2000,2001,2004,2005,2006,2007,2015,2016,2017,2018,2019,2020 ./lib/dns/db.c C 1999,2000,2001,2003,2004,2005,2007,2008,2009,2011,2012,2013,2015,2016,2017,2018,2019 ./lib/dns/dbiterator.c C 1999,2000,2001,2004,2005,2007,2016,2018,2019,2020 -./lib/dns/dbtable.c C 1999,2000,2001,2004,2005,2007,2013,2016,2018,2019,2020 ./lib/dns/diff.c C 2000,2001,2002,2003,2004,2005,2007,2008,2009,2011,2013,2014,2015,2016,2017,2018,2019,2020 ./lib/dns/dispatch.c C 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020 ./lib/dns/dlz.c C.PORTION 1999,2000,2001,2005,2007,2009,2010,2011,2012,2013,2015,2016,2018,2019,2020 @@ -1321,7 +1320,6 @@ ./lib/dns/include/dns/compress.h C 1999,2000,2001,2002,2004,2005,2006,2007,2009,2015,2016,2017,2018,2019,2020 ./lib/dns/include/dns/db.h C 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2011,2012,2013,2014,2015,2016,2017,2018,2019 ./lib/dns/include/dns/dbiterator.h C 1999,2000,2001,2004,2005,2006,2007,2016,2018,2019,2020 -./lib/dns/include/dns/dbtable.h C 1999,2000,2001,2004,2005,2006,2007,2016,2018,2019,2020 ./lib/dns/include/dns/diff.h C 2000,2001,2004,2005,2006,2007,2008,2009,2010,2013,2016,2018,2019,2020 ./lib/dns/include/dns/dispatch.h C 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020 ./lib/dns/include/dns/dlz.h C.PORTION 1999,2000,2001,2005,2006,2007,2009,2010,2011,2012,2013,2016,2018,2019,2020