From d39b3209fbd07245441da61bf2188f5eac824820 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Witold=20Kr=C4=99cicki?= Date: Tue, 3 Apr 2018 13:10:15 +0200 Subject: [PATCH] libdns refactoring: get rid of 3 versions of dns_cache_create --- bin/named/server.c | 8 ++++---- bin/tests/optional/adb_test.c | 5 +++-- bin/tests/optional/byaddr_test.c | 4 ++-- bin/tests/optional/byname_test.c | 4 ++-- lib/dns/cache.c | 27 +++------------------------ lib/dns/include/dns/cache.h | 17 +++-------------- lib/dns/win32/libdns.def.in | 2 -- lib/ns/tests/nstest.c | 4 ++-- 8 files changed, 19 insertions(+), 52 deletions(-) diff --git a/bin/named/server.c b/bin/named/server.c index 99f11bc92c..7240d5f8c0 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -4208,10 +4208,10 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, isc_mem_setname(cmctx, "cache", NULL); CHECK(isc_mem_create(0, 0, &hmctx)); isc_mem_setname(hmctx, "cache_heap", NULL); - CHECK(dns_cache_create3(cmctx, hmctx, named_g_taskmgr, - named_g_timermgr, view->rdclass, - cachename, "rbt", 0, NULL, - &cache)); + CHECK(dns_cache_create(cmctx, hmctx, named_g_taskmgr, + named_g_timermgr, view->rdclass, + cachename, "rbt", 0, NULL, + &cache)); isc_mem_detach(&cmctx); isc_mem_detach(&hmctx); } diff --git a/bin/tests/optional/adb_test.c b/bin/tests/optional/adb_test.c index 97bf3cfaf9..0d6995d9c3 100644 --- a/bin/tests/optional/adb_test.c +++ b/bin/tests/optional/adb_test.c @@ -180,8 +180,9 @@ create_view(void) { * Cache. */ cache = NULL; - result = dns_cache_create(mctx, taskmgr, timermgr, dns_rdataclass_in, - "rbt", 0, NULL, &cache); + result = dns_cache_create(mctx, mctx, taskmgr, timermgr, + dns_rdataclass_in, "", "rbt", 0, NULL, + &cache); check_result(result, "dns_cache_create"); dns_view_setcache(view, cache); dns_cache_detach(&cache); diff --git a/bin/tests/optional/byaddr_test.c b/bin/tests/optional/byaddr_test.c index 39b8b253e9..7d95c05bb5 100644 --- a/bin/tests/optional/byaddr_test.c +++ b/bin/tests/optional/byaddr_test.c @@ -132,8 +132,8 @@ main(int argc, char *argv[]) { RUNTIME_CHECK(isc_socketmgr_create(mctx, &socketmgr) == ISC_R_SUCCESS); cache = NULL; - RUNTIME_CHECK(dns_cache_create(mctx, taskmgr, timermgr, - dns_rdataclass_in, "rbt", 0, NULL, + RUNTIME_CHECK(dns_cache_create(mctx, mctx, taskmgr, timermgr, + dns_rdataclass_in, "", "rbt", 0, NULL, &cache) == ISC_R_SUCCESS); view = NULL; diff --git a/bin/tests/optional/byname_test.c b/bin/tests/optional/byname_test.c index fb4b2b8413..89c9a263dd 100644 --- a/bin/tests/optional/byname_test.c +++ b/bin/tests/optional/byname_test.c @@ -250,8 +250,8 @@ main(int argc, char *argv[]) { RUNTIME_CHECK(isc_socketmgr_create(mctx, &socketmgr) == ISC_R_SUCCESS); cache = NULL; - RUNTIME_CHECK(dns_cache_create(mctx, taskmgr, timermgr, - dns_rdataclass_in, "rbt", 0, NULL, + RUNTIME_CHECK(dns_cache_create(mctx, mctx, taskmgr, timermgr, + dns_rdataclass_in, "", "rbt", 0, NULL, &cache) == ISC_R_SUCCESS); view = NULL; diff --git a/lib/dns/cache.c b/lib/dns/cache.c index ce40969889..d37a018d09 100644 --- a/lib/dns/cache.c +++ b/lib/dns/cache.c @@ -176,31 +176,10 @@ cache_create_db(dns_cache_t *cache, dns_db_t **db) { } isc_result_t -dns_cache_create(isc_mem_t *cmctx, isc_taskmgr_t *taskmgr, +dns_cache_create(isc_mem_t *cmctx, isc_mem_t *hmctx, isc_taskmgr_t *taskmgr, isc_timermgr_t *timermgr, dns_rdataclass_t rdclass, - const char *db_type, unsigned int db_argc, char **db_argv, - dns_cache_t **cachep) -{ - return (dns_cache_create3(cmctx, cmctx, taskmgr, timermgr, rdclass, "", - db_type, db_argc, db_argv, cachep)); -} - -isc_result_t -dns_cache_create2(isc_mem_t *cmctx, isc_taskmgr_t *taskmgr, - isc_timermgr_t *timermgr, dns_rdataclass_t rdclass, - const char *cachename, const char *db_type, - unsigned int db_argc, char **db_argv, dns_cache_t **cachep) -{ - return (dns_cache_create3(cmctx, cmctx, taskmgr, timermgr, rdclass, - cachename, db_type, db_argc, db_argv, - cachep)); -} - -isc_result_t -dns_cache_create3(isc_mem_t *cmctx, isc_mem_t *hmctx, isc_taskmgr_t *taskmgr, - isc_timermgr_t *timermgr, dns_rdataclass_t rdclass, - const char *cachename, const char *db_type, - unsigned int db_argc, char **db_argv, dns_cache_t **cachep) + const char *cachename, const char *db_type, + unsigned int db_argc, char **db_argv, dns_cache_t **cachep) { isc_result_t result; dns_cache_t *cache; diff --git a/lib/dns/include/dns/cache.h b/lib/dns/include/dns/cache.h index 290a4e801b..74b3b32f08 100644 --- a/lib/dns/include/dns/cache.h +++ b/lib/dns/include/dns/cache.h @@ -55,22 +55,11 @@ ISC_LANG_BEGINDECLS /*** *** Functions ***/ - isc_result_t -dns_cache_create(isc_mem_t *cmctx, isc_taskmgr_t *taskmgr, +dns_cache_create(isc_mem_t *cmctx, isc_mem_t *hmctx, isc_taskmgr_t *taskmgr, isc_timermgr_t *timermgr, dns_rdataclass_t rdclass, - const char *db_type, unsigned int db_argc, char **db_argv, - dns_cache_t **cachep); -isc_result_t -dns_cache_create2(isc_mem_t *cmctx, isc_taskmgr_t *taskmgr, - isc_timermgr_t *timermgr, dns_rdataclass_t rdclass, - const char *cachename, const char *db_type, - unsigned int db_argc, char **db_argv, dns_cache_t **cachep); -isc_result_t -dns_cache_create3(isc_mem_t *cmctx, isc_mem_t *hmctx, isc_taskmgr_t *taskmgr, - isc_timermgr_t *timermgr, dns_rdataclass_t rdclass, - const char *cachename, const char *db_type, - unsigned int db_argc, char **db_argv, dns_cache_t **cachep); + const char *cachename, const char *db_type, + unsigned int db_argc, char **db_argv, dns_cache_t **cachep); /*%< * Create a new DNS cache. * diff --git a/lib/dns/win32/libdns.def.in b/lib/dns/win32/libdns.def.in index 8b4f811b7a..440af9b98a 100644 --- a/lib/dns/win32/libdns.def.in +++ b/lib/dns/win32/libdns.def.in @@ -73,8 +73,6 @@ dns_cache_attach dns_cache_attachdb dns_cache_clean dns_cache_create -dns_cache_create2 -dns_cache_create3 dns_cache_detach dns_cache_dump dns_cache_dumpstats diff --git a/lib/ns/tests/nstest.c b/lib/ns/tests/nstest.c index 620636d8f5..696ddd2b82 100644 --- a/lib/ns/tests/nstest.c +++ b/lib/ns/tests/nstest.c @@ -321,8 +321,8 @@ ns_test_makeview(const char *name, isc_boolean_t with_cache, CHECK(dns_view_create(mctx, dns_rdataclass_in, name, &view)); if (with_cache) { - CHECK(dns_cache_create(mctx, taskmgr, timermgr, - dns_rdataclass_in, "rbt", 0, NULL, + CHECK(dns_cache_create(mctx, mctx, taskmgr, timermgr, + dns_rdataclass_in, "", "rbt", 0, NULL, &cache)); dns_view_setcache(view, cache); /*