From: Ondřej Surý Date: Mon, 30 Oct 2017 13:42:26 +0000 (+0100) Subject: Remove whole unused ondestroy callback mechanism X-Git-Tag: v9.13.0~169^2~1 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=4ff2d36adc5d46ce8c03de383b37b4fecb03803b;p=thirdparty%2Fbind9.git Remove whole unused ondestroy callback mechanism --- diff --git a/bin/tests/system/dyndb/driver/db.c b/bin/tests/system/dyndb/driver/db.c index f3f03c8dde2..eebe621880f 100644 --- a/bin/tests/system/dyndb/driver/db.c +++ b/bin/tests/system/dyndb/driver/db.c @@ -760,7 +760,6 @@ create_db(isc_mem_t *mctx, const dns_name_t *origin, dns_dbtype_t type, isc_mem_attach(mctx, &sampledb->common.mctx); dns_name_init(&sampledb->common.origin, NULL); - isc_ondestroy_init(&sampledb->common.ondest); sampledb->common.magic = DNS_DB_MAGIC; sampledb->common.impmagic = SAMPLEDB_MAGIC; diff --git a/lib/dns/db.c b/lib/dns/db.c index 7b77b13298a..79357451e0e 100644 --- a/lib/dns/db.c +++ b/lib/dns/db.c @@ -166,14 +166,6 @@ dns_db_detach(dns_db_t **dbp) { ENSURE(*dbp == NULL); } -isc_result_t -dns_db_ondestroy(dns_db_t *db, isc_task_t *task, isc_event_t **eventp) -{ - REQUIRE(DNS_DB_VALID(db)); - - return (isc_ondestroy_register(&db->ondest, task, eventp)); -} - isc_boolean_t dns_db_iscache(dns_db_t *db) { diff --git a/lib/dns/include/dns/db.h b/lib/dns/include/dns/db.h index 0eb310aa1c2..71ae2f6651d 100644 --- a/lib/dns/include/dns/db.h +++ b/lib/dns/include/dns/db.h @@ -48,7 +48,6 @@ #include #include #include -#include #include #include @@ -223,7 +222,6 @@ struct dns_db { isc_uint16_t attributes; dns_rdataclass_t rdclass; dns_name_t origin; - isc_ondestroy_t ondest; isc_mem_t * mctx; ISC_LIST(dns_dbonupdatelistener_t) update_listeners; }; @@ -360,17 +358,6 @@ dns_db_detach(dns_db_t **dbp); * all resources used by the database will be freed */ -isc_result_t -dns_db_ondestroy(dns_db_t *db, isc_task_t *task, isc_event_t **eventp); -/*%< - * Causes 'eventp' to be sent to be sent to 'task' when the database is - * destroyed. - * - * Note; ownership of the eventp is taken from the caller (and *eventp is - * set to NULL). The sender field of the event is set to 'db' before it is - * sent to the task. - */ - isc_boolean_t dns_db_iscache(dns_db_t *db); /*%< diff --git a/lib/dns/include/dns/rriterator.h b/lib/dns/include/dns/rriterator.h index 63a0380b46b..c855ea5b9ea 100644 --- a/lib/dns/include/dns/rriterator.h +++ b/lib/dns/include/dns/rriterator.h @@ -26,7 +26,6 @@ #include #include -#include #include #include diff --git a/lib/dns/rbtdb.c b/lib/dns/rbtdb.c index 82d1801edff..ca9b605c166 100644 --- a/lib/dns/rbtdb.c +++ b/lib/dns/rbtdb.c @@ -1190,7 +1190,6 @@ adjust_quantum(unsigned int old, isc_time_t *start) { static void free_rbtdb(dns_rbtdb_t *rbtdb, isc_boolean_t log, isc_event_t *event) { unsigned int i; - isc_ondestroy_t ondest; isc_result_t result; char buf[DNS_NAME_FORMATSIZE]; dns_rbt_t **treep; @@ -1338,7 +1337,6 @@ free_rbtdb(dns_rbtdb_t *rbtdb, isc_boolean_t log, isc_event_t *event) { RBTDB_DESTROYLOCK(&rbtdb->lock); rbtdb->common.magic = 0; rbtdb->common.impmagic = 0; - ondest = rbtdb->common.ondest; isc_mem_detach(&rbtdb->hmctx); if (rbtdb->mmap_location != NULL) @@ -1356,7 +1354,6 @@ free_rbtdb(dns_rbtdb_t *rbtdb, isc_boolean_t log, isc_event_t *event) { } isc_mem_putanddetach(&rbtdb->common.mctx, rbtdb, sizeof(*rbtdb)); - isc_ondestroy_notify(&ondest, rbtdb); } static inline void @@ -8603,11 +8600,6 @@ dns_rbtdb_create isc_mem_attach(mctx, &rbtdb->common.mctx); isc_mem_attach(hmctx, &rbtdb->hmctx); - /* - * Must be initialized before free_rbtdb() is called. - */ - isc_ondestroy_init(&rbtdb->common.ondest); - /* * Make a copy of the origin name. */ diff --git a/lib/dns/win32/libdns.def.in b/lib/dns/win32/libdns.def.in index cb7fbd40b79..6eefb2af1b1 100644 --- a/lib/dns/win32/libdns.def.in +++ b/lib/dns/win32/libdns.def.in @@ -224,7 +224,6 @@ dns_db_load3 dns_db_newversion dns_db_nodecount dns_db_nodefullname -dns_db_ondestroy dns_db_origin dns_db_overmem dns_db_printnode diff --git a/lib/dns/zone.c b/lib/dns/zone.c index ed9ae40c7c1..12875f90a0c 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -763,12 +763,6 @@ static void zone_rdclass_tostr(dns_zone_t *zone, char *buf, size_t length); static void zone_viewname_tostr(dns_zone_t *zone, char *buf, size_t length); static isc_result_t zone_send_secureserial(dns_zone_t *zone, isc_uint32_t serial); - -#if 0 -/* ondestroy example */ -static void dns_zonemgr_dbdestroyed(isc_task_t *task, isc_event_t *event); -#endif - static void refresh_callback(isc_task_t *, isc_event_t *); static void stub_callback(isc_task_t *, isc_event_t *); static void queue_soa_query(dns_zone_t *zone); @@ -4785,18 +4779,6 @@ zone_postload(dns_zone_t *zone, dns_db_t *db, isc_time_t loadtime, DNS_ZONEKEY_OPTION(zone, DNS_ZONEKEY_MAINTAIN)) zone->refreshkeytime = now; -#if 0 - /* destroy notification example. */ - { - isc_event_t *e = isc_event_allocate(zone->mctx, NULL, - DNS_EVENT_DBDESTROYED, - dns_zonemgr_dbdestroyed, - zone, - sizeof(isc_event_t)); - dns_db_ondestroy(db, zone->task, &e); - } -#endif - ZONEDB_LOCK(&zone->dblock, isc_rwlocktype_write); if (zone->db != NULL) { result = zone_replacedb(zone, db, ISC_FALSE); @@ -16724,22 +16706,6 @@ zone_saveunique(dns_zone_t *zone, const char *path, const char *templat) { isc_mem_put(zone->mctx, buf, buflen); } -#if 0 -/* Hook for ondestroy notification from a database. */ - -static void -dns_zonemgr_dbdestroyed(isc_task_t *task, isc_event_t *event) { - dns_db_t *db = event->sender; - UNUSED(task); - - isc_event_free(&event); - - isc_log_write(dns_lctx, DNS_LOGCATEGORY_GENERAL, - DNS_LOGMODULE_ZONE, ISC_LOG_DEBUG(3), - "database (%p) destroyed", (void*) db); -} -#endif - static void setrl(isc_ratelimiter_t *rl, unsigned int *rate, unsigned int value) { isc_interval_t interval; diff --git a/lib/isc/Makefile.in b/lib/isc/Makefile.in index bd8b109148e..03671b9ee64 100644 --- a/lib/isc/Makefile.in +++ b/lib/isc/Makefile.in @@ -53,7 +53,7 @@ OBJS = @ISC_EXTRA_OBJS@ @ISC_PK11_O@ @ISC_PK11_RESULT_O@ \ hmacsha.@O@ httpd.@O@ inet_aton.@O@ iterated_hash.@O@ \ lex.@O@ lfsr.@O@ lib.@O@ log.@O@ \ md5.@O@ mem.@O@ mutexblock.@O@ \ - netaddr.@O@ netscope.@O@ pool.@O@ ondestroy.@O@ \ + netaddr.@O@ netscope.@O@ pool.@O@ \ parseint.@O@ portset.@O@ quota.@O@ radix.@O@ random.@O@ \ ratelimiter.@O@ refcount.@O@ region.@O@ regex.@O@ result.@O@ \ rwlock.@O@ \ @@ -73,7 +73,7 @@ SRCS = @ISC_EXTRA_SRCS@ @ISC_PK11_C@ @ISC_PK11_RESULT_C@ \ hmacsha.c httpd.c inet_aton.c iterated_hash.c \ lex.c lfsr.c lib.c log.c \ md5.c mem.c mutexblock.c \ - netaddr.c netscope.c pool.c ondestroy.c \ + netaddr.c netscope.c pool.c \ parseint.c portset.c quota.c radix.c random.c ${CHACHASRCS} \ ratelimiter.c refcount.c region.c regex.c result.c rwlock.c \ safe.c serial.c sha1.c sha2.c sockaddr.c stats.c string.c \ diff --git a/lib/isc/include/isc/Makefile.in b/lib/isc/include/isc/Makefile.in index 26d4203b14c..c85645e0349 100644 --- a/lib/isc/include/isc/Makefile.in +++ b/lib/isc/include/isc/Makefile.in @@ -24,7 +24,7 @@ HEADERS = aes.h app.h assertions.h backtrace.h base32.h base64.h \ interfaceiter.h @ISC_IPV6_H@ iterated_hash.h \ json.h lang.h lex.h lfsr.h lib.h likely.h list.h log.h \ magic.h md5.h mem.h meminfo.h msgcat.h msgs.h mutexblock.h \ - netaddr.h netscope.h ondestroy.h os.h parseint.h \ + netaddr.h netscope.h os.h parseint.h \ pool.h portset.h print.h queue.h quota.h \ radix.h random.h ratelimiter.h refcount.h regex.h \ region.h resource.h result.h resultclass.h rwlock.h \ diff --git a/lib/isc/include/isc/mem.h b/lib/isc/include/isc/mem.h index 4f5f209cab8..69d2d176510 100644 --- a/lib/isc/include/isc/mem.h +++ b/lib/isc/include/isc/mem.h @@ -344,15 +344,6 @@ isc_mem_destroy(isc_mem_t **); * Destroy a memory context. */ -isc_result_t -isc_mem_ondestroy(isc_mem_t *ctx, - isc_task_t *task, - isc_event_t **event); -/*%< - * Request to be notified with an event when a memory context has - * been successfully destroyed. - */ - void isc_mem_stats(isc_mem_t *mctx, FILE *out); /*%< diff --git a/lib/isc/include/isc/ondestroy.h b/lib/isc/include/isc/ondestroy.h deleted file mode 100644 index d48c08bb5bb..00000000000 --- a/lib/isc/include/isc/ondestroy.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (C) 2000, 2001, 2004-2007, 2016 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 http://mozilla.org/MPL/2.0/. - */ - -/* $Id: ondestroy.h,v 1.14 2007/06/19 23:47:18 tbox Exp $ */ - -#ifndef ISC_ONDESTROY_H -#define ISC_ONDESTROY_H 1 - -#include -#include - -ISC_LANG_BEGINDECLS - -/*! \file isc/ondestroy.h - * ondestroy handling. - * - * Any class ``X'' of objects that wants to send out notifications - * on its destruction should declare a field of type isc_ondestroy_t - * (call it 'ondest'). - * - * \code - * typedef struct { - * ... - * isc_ondestroy_t ondest; - * ... - * } X; - * \endcode - * - * When an object ``A'' of type X is created - * it must initialize the field ondest with a call to - * - * \code - * isc_ondestroy_init(&A->ondest). - * \endcode - * - * X should also provide a registration function for third-party - * objects to call to register their interest in being told about - * the destruction of a particular instance of X. - * - * \code - * isc_result_t - * X_ondestroy(X *instance, isc_task_t *task, - * isc_event_t **eventp) { - * return(isc_ondestroy_register(&instance->ondest, task,eventp)); - * } - * \endcode - * - * Note: locking of the ondestory structure embedded inside of X, is - * X's responsibility. - * - * When an instance of X is destroyed, a call to isc_ondestroy_notify() - * sends the notifications: - * - * \code - * X *instance; - * isc_ondestroy_t ondest = instance->ondest; - * - * ... completely cleanup 'instance' here... - * - * isc_ondestroy_notify(&ondest, instance); - * \endcode - * - * - * see lib/dns/zone.c for an ifdef'd-out example. - */ - -struct isc_ondestroy { - unsigned int magic; - isc_eventlist_t events; -}; - -void -isc_ondestroy_init(isc_ondestroy_t *ondest); -/*%< - * Initialize the on ondest structure. *must* be called before first call - * to isc_ondestroy_register(). - */ - -isc_result_t -isc_ondestroy_register(isc_ondestroy_t *ondest, isc_task_t *task, - isc_event_t **eventp); - -/*%< - * Stores task and *eventp away inside *ondest. Ownership of **event is - * taken from the caller (and *eventp is set to NULL). The task is attached - * to. - */ - -void -isc_ondestroy_notify(isc_ondestroy_t *ondest, void *sender); -/*%< - * Dispatches the event(s) to the task(s) that were given in - * isc_ondestroy_register call(s) (done via calls to - * isc_task_sendanddetach()). Before dispatch, the sender value of each - * event structure is set to the value of the sender paramater. The - * internal structures of the ondest parameter are cleaned out, so no other - * cleanup is needed. - */ - -ISC_LANG_ENDDECLS - -#endif /* ISC_ONDESTROY_H */ diff --git a/lib/isc/include/isc/types.h b/lib/isc/include/isc/types.h index da38713d7a4..59968a55d54 100644 --- a/lib/isc/include/isc/types.h +++ b/lib/isc/include/isc/types.h @@ -64,7 +64,6 @@ typedef struct isc_logmodule isc_logmodule_t; /*%< Log Module */ typedef struct isc_mem isc_mem_t; /*%< Memory */ typedef struct isc_mempool isc_mempool_t; /*%< Memory Pool */ typedef struct isc_msgcat isc_msgcat_t; /*%< Message Catalog */ -typedef struct isc_ondestroy isc_ondestroy_t; /*%< On Destroy */ typedef struct isc_netaddr isc_netaddr_t; /*%< Net Address */ typedef struct isc_portset isc_portset_t; /*%< Port Set */ typedef struct isc_quota isc_quota_t; /*%< Quota */ diff --git a/lib/isc/mem.c b/lib/isc/mem.c index b2898c63658..8e10d16ad9f 100644 --- a/lib/isc/mem.c +++ b/lib/isc/mem.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include @@ -117,7 +116,6 @@ static isc_uint64_t totallost; struct isc__mem { isc_mem_t common; - isc_ondestroy_t ondestroy; unsigned int flags; isc_mutex_t lock; isc_memalloc_t memalloc; @@ -234,8 +232,6 @@ void isc___mem_putanddetach(isc_mem_t **ctxp, void *ptr, size_t size FLARG); void isc__mem_destroy(isc_mem_t **ctxp); -isc_result_t -isc__mem_ondestroy(isc_mem_t *ctx, isc_task_t *task, isc_event_t **event); void * isc___mem_get(isc_mem_t *ctx, size_t size FLARG); void @@ -314,7 +310,7 @@ static struct isc__memmethods { /*% * The following are defined just for avoiding unused static functions. */ - void *createx, *create, *create2, *ondestroy, *stats, + void *createx, *create, *create2, *stats, *setquota, *getquota, *setname, *getname, *gettag; } memmethods = { { @@ -340,7 +336,6 @@ static struct isc__memmethods { (void *)isc_mem_createx, (void *)isc_mem_create, (void *)isc_mem_create2, - (void *)isc_mem_ondestroy, (void *)isc_mem_stats, (void *)isc_mem_setquota, (void *)isc_mem_getquota, @@ -938,7 +933,6 @@ isc_mem_createx2(size_t init_max_size, size_t target_size, ctx->common.impmagic = MEM_MAGIC; ctx->common.magic = ISCAPI_MCTX_MAGIC; ctx->common.methods = (isc_memmethods_t *)&memmethods; - isc_ondestroy_init(&ctx->ondestroy); ctx->memalloc = memalloc; ctx->memfree = memfree; ctx->arg = arg; @@ -1032,7 +1026,6 @@ isc_mem_createx2(size_t init_max_size, size_t target_size, static void destroy(isc__mem_t *ctx) { unsigned int i; - isc_ondestroy_t ondest; LOCK(&contextslock); ISC_LIST_UNLINK(contexts, ctx, link); @@ -1100,16 +1093,12 @@ destroy(isc__mem_t *ctx) { } } - ondest = ctx->ondestroy; - if ((ctx->flags & ISC_MEMFLAG_NOLOCK) == 0) DESTROYLOCK(&ctx->lock); ctx->malloced -= sizeof(*ctx); if (ctx->checkfree) INSIST(ctx->malloced == 0); (ctx->memfree)(ctx->arg, ctx); - - isc_ondestroy_notify(&ondest, ctx); } void @@ -1248,18 +1237,6 @@ isc__mem_destroy(isc_mem_t **ctxp) { *ctxp = NULL; } -isc_result_t -isc_mem_ondestroy(isc_mem_t *ctx0, isc_task_t *task, isc_event_t **event) { - isc__mem_t *ctx = (isc__mem_t *)ctx0; - isc_result_t res; - - MCTXLOCK(ctx, &ctx->lock); - res = isc_ondestroy_register(&ctx->ondestroy, task, event); - MCTXUNLOCK(ctx, &ctx->lock); - - return (res); -} - void * isc___mem_get(isc_mem_t *ctx0, size_t size FLARG) { isc__mem_t *ctx = (isc__mem_t *)ctx0; diff --git a/lib/isc/ondestroy.c b/lib/isc/ondestroy.c deleted file mode 100644 index 1a331df7620..00000000000 --- a/lib/isc/ondestroy.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2000, 2001, 2004, 2005, 2007, 2016 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 http://mozilla.org/MPL/2.0/. - */ - -/* $Id: ondestroy.c,v 1.16 2007/06/19 23:47:17 tbox Exp $ */ - -/*! \file */ - -#include - -#include - -#include -#include -#include -#include -#include - -#define ONDESTROY_MAGIC ISC_MAGIC('D', 'e', 'S', 't') -#define VALID_ONDESTROY(s) ISC_MAGIC_VALID(s, ONDESTROY_MAGIC) - -void -isc_ondestroy_init(isc_ondestroy_t *ondest) { - ondest->magic = ONDESTROY_MAGIC; - ISC_LIST_INIT(ondest->events); -} - -isc_result_t -isc_ondestroy_register(isc_ondestroy_t *ondest, isc_task_t *task, - isc_event_t **eventp) -{ - isc_event_t *theevent; - isc_task_t *thetask = NULL; - - REQUIRE(VALID_ONDESTROY(ondest)); - REQUIRE(task != NULL); - REQUIRE(eventp != NULL); - - theevent = *eventp; - - REQUIRE(theevent != NULL); - - isc_task_attach(task, &thetask); - - theevent->ev_sender = thetask; - - ISC_LIST_APPEND(ondest->events, theevent, ev_link); - - return (ISC_R_SUCCESS); -} - -void -isc_ondestroy_notify(isc_ondestroy_t *ondest, void *sender) { - isc_event_t *eventp; - isc_task_t *task; - - REQUIRE(VALID_ONDESTROY(ondest)); - - eventp = ISC_LIST_HEAD(ondest->events); - while (eventp != NULL) { - ISC_LIST_UNLINK(ondest->events, eventp, ev_link); - - task = eventp->ev_sender; - eventp->ev_sender = sender; - - isc_task_sendanddetach(&task, &eventp); - - eventp = ISC_LIST_HEAD(ondest->events); - } -} - - diff --git a/lib/isc/win32/libisc.def.in b/lib/isc/win32/libisc.def.in index f13d8becb7a..cf27a6f899c 100644 --- a/lib/isc/win32/libisc.def.in +++ b/lib/isc/win32/libisc.def.in @@ -428,7 +428,6 @@ isc_mem_gettag isc_mem_inuse isc_mem_isovermem isc_mem_maxinuse -isc_mem_ondestroy isc_mem_printallactive isc_mem_references isc_mem_register @@ -503,9 +502,6 @@ isc_netscope_pton isc_ntpaths_get isc_ntpaths_init isc_once_do -isc_ondestroy_init -isc_ondestroy_notify -isc_ondestroy_register isc_os_ncpus isc_parse_uint16 isc_parse_uint32 diff --git a/lib/isc/win32/libisc.vcxproj.filters.in b/lib/isc/win32/libisc.vcxproj.filters.in index 1ffb4510533..44cdd9dd3a2 100644 --- a/lib/isc/win32/libisc.vcxproj.filters.in +++ b/lib/isc/win32/libisc.vcxproj.filters.in @@ -166,9 +166,6 @@ Library Header Files - - Library Header Files - Library Header Files @@ -588,9 +585,6 @@ Library Source Files - - Library Source Files - Library Source Files diff --git a/lib/isc/win32/libisc.vcxproj.in b/lib/isc/win32/libisc.vcxproj.in index 6c888e5934c..c1125b493b4 100644 --- a/lib/isc/win32/libisc.vcxproj.in +++ b/lib/isc/win32/libisc.vcxproj.in @@ -343,7 +343,6 @@ copy InstallFiles ..\Build\Release\ - @@ -462,7 +461,6 @@ copy InstallFiles ..\Build\Release\ - diff --git a/util/copyrights b/util/copyrights index f323b5659fe..3ec08dd0967 100644 --- a/util/copyrights +++ b/util/copyrights @@ -3893,7 +3893,6 @@ ./lib/isc/include/isc/mutexblock.h C 1999,2000,2001,2004,2005,2006,2007,2016 ./lib/isc/include/isc/netaddr.h C 1998,1999,2000,2001,2002,2004,2005,2006,2007,2009,2015,2016,2017 ./lib/isc/include/isc/netscope.h C 2002,2004,2005,2006,2007,2009,2016 -./lib/isc/include/isc/ondestroy.h C 2000,2001,2004,2005,2006,2007,2016 ./lib/isc/include/isc/os.h C 2000,2001,2004,2005,2006,2007,2016 ./lib/isc/include/isc/parseint.h C 2001,2002,2004,2005,2006,2007,2016 ./lib/isc/include/isc/platform.h.in C 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2013,2014,2015,2016,2017 @@ -3976,7 +3975,6 @@ ./lib/isc/nothreads/include/isc/thread.h C 2000,2001,2004,2007,2013,2016,2017 ./lib/isc/nothreads/mutex.c C 2000,2001,2004,2006,2007,2016 ./lib/isc/nothreads/thread.c C 2000,2001,2004,2007,2016,2017 -./lib/isc/ondestroy.c C 2000,2001,2004,2005,2007,2016 ./lib/isc/parseint.c C 2001,2002,2003,2004,2005,2007,2012,2016 ./lib/isc/pk11.c C 2014,2015,2016,2017 ./lib/isc/pk11_result.c C 2014,2015,2016