Commit 4ff2d36a authored by Ondřej Surý's avatar Ondřej Surý

Remove whole unused ondestroy callback mechanism

parent 313e7335
......@@ -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;
......
......@@ -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) {
......
......@@ -48,7 +48,6 @@
#include <isc/deprecated.h>
#include <isc/lang.h>
#include <isc/magic.h>
#include <isc/ondestroy.h>
#include <isc/stats.h>
#include <isc/stdtime.h>
......@@ -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);
/*%<
......
......@@ -26,7 +26,6 @@
#include <isc/lang.h>
#include <isc/magic.h>
#include <isc/ondestroy.h>
#include <isc/stdtime.h>
#include <dns/db.h>
......
......@@ -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.
*/
......
......@@ -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
......
......@@ -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;
......
......@@ -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 \
......
......@@ -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 \
......
......@@ -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);
/*%<
......
/*
* 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 <isc/lang.h>
#include <isc/types.h>
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 */
......@@ -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 */
......
......@@ -23,7 +23,6 @@
#include <isc/mem.h>
#include <isc/msgs.h>
#include <isc/once.h>
#include <isc/ondestroy.h>
#include <isc/string.h>
#include <isc/mutex.h>
#include <isc/print.h>
......@@ -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;
......
/*
* 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 <config.h>
#include <stddef.h>
#include <isc/event.h>
#include <isc/magic.h>
#include <isc/ondestroy.h>
#include <isc/task.h>
#include <isc/util.h>
#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);
}
}
......@@ -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
......
......@@ -166,9 +166,6 @@
<ClInclude Include="..\include\isc\netscope.h">
<Filter>Library Header Files</Filter>
</ClInclude>
<ClInclude Include="..\include\isc\ondestroy.h">
<Filter>Library Header Files</Filter>
</ClInclude>
<ClInclude Include="..\include\isc\os.h">
<Filter>Library Header Files</Filter>
</ClInclude>
......@@ -588,9 +585,6 @@
<ClCompile Include="..\netscope.c">
<Filter>Library Source Files</Filter>
</ClCompile>
<ClCompile Include="..\ondestroy.c">
<Filter>Library Source Files</Filter>
</ClCompile>
<ClCompile Include="..\parseint.c">
<Filter>Library Source Files</Filter>
</ClCompile>
......
......@@ -343,7 +343,6 @@ copy InstallFiles ..\Build\Release\
<ClInclude Include="..\include\isc\mutexblock.h" />
<ClInclude Include="..\include\isc\netaddr.h" />
<ClInclude Include="..\include\isc\netscope.h" />
<ClInclude Include="..\include\isc\ondestroy.h" />
<ClInclude Include="..\include\isc\os.h" />
<ClInclude Include="..\include\isc\parseint.h" />
<ClInclude Include="..\include\isc\pool.h" />
......@@ -462,7 +461,6 @@ copy InstallFiles ..\Build\Release\
<ClCompile Include="..\netaddr.c" />
<ClCompile Include="..\netscope.c" />
<ClCompile Include="..\nls\msgcat.c" />
<ClCompile Include="..\ondestroy.c" />
<ClCompile Include="..\parseint.c" />
<ClCompile Include="..\pool.c" />
<ClCompile Include="..\portset.c" />
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment