From: Ondřej Surý Date: Tue, 26 Jul 2022 11:03:01 +0000 (+0200) Subject: Simplify the isc_event API X-Git-Tag: v9.19.5~23^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a26862e6538c60976afb08bd0f6dccb78d48b1c8;p=thirdparty%2Fbind9.git Simplify the isc_event API The ev_tag field was never used, and has now been removed. --- diff --git a/lib/dns/adb.c b/lib/dns/adb.c index bca098f016e..ef52a778d16 100644 --- a/lib/dns/adb.c +++ b/lib/dns/adb.c @@ -1489,7 +1489,7 @@ new_adbfind(dns_adb_t *adb, in_port_t port) { ISC_LINK_INIT(find, plink); ISC_LIST_INIT(find->list); isc_mutex_init(&find->lock); - ISC_EVENT_INIT(&find->event, sizeof(isc_event_t), 0, 0, 0, NULL, NULL, + ISC_EVENT_INIT(&find->event, sizeof(isc_event_t), 0, 0, NULL, NULL, NULL, NULL, find); find->magic = DNS_ADBFIND_MAGIC; diff --git a/lib/dns/catz.c b/lib/dns/catz.c index c926be424c7..8cf4e1cb938 100644 --- a/lib/dns/catz.c +++ b/lib/dns/catz.c @@ -2065,7 +2065,7 @@ dns_catz_dbupdate_callback(dns_db_t *db, void *fn_arg) { dns_db_currentversion(db, &zone->dbversion); ISC_EVENT_INIT(&zone->updateevent, - sizeof(zone->updateevent), 0, NULL, + sizeof(zone->updateevent), 0, DNS_EVENT_CATZUPDATED, dns_catz_update_taskaction, zone, zone, NULL, NULL); diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index 3155da1a549..83293f7d675 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -4572,7 +4572,7 @@ fctx_start(isc_task_t *task, isc_event_t *event) { * Reset the control event for later use in shutting * down the fctx. */ - ISC_EVENT_INIT(event, sizeof(*event), 0, NULL, DNS_EVENT_FETCHCONTROL, + ISC_EVENT_INIT(event, sizeof(*event), 0, DNS_EVENT_FETCHCONTROL, fctx_doshutdown, fctx, NULL, NULL, NULL); UNLOCK(&fctx->bucket->lock); @@ -10808,7 +10808,7 @@ dns_resolver_createfetch(dns_resolver_t *res, const dns_name_t *name, */ event = &fctx->control_event; fctx_addref(fctx); - ISC_EVENT_INIT(event, sizeof(*event), 0, NULL, + ISC_EVENT_INIT(event, sizeof(*event), 0, DNS_EVENT_FETCHCONTROL, fctx_start, fctx, NULL, NULL, NULL); isc_task_send(fctx->restask, &event); diff --git a/lib/dns/rpz.c b/lib/dns/rpz.c index 20632eefe9f..62b150f6d87 100644 --- a/lib/dns/rpz.c +++ b/lib/dns/rpz.c @@ -1542,8 +1542,8 @@ dns_rpz_new_zone(dns_rpz_zones_t *rpzs, dns_rpz_zone_t **rpzp) { rpz_attach_rpzs(rpzs, &rpz->rpzs); - ISC_EVENT_INIT(&rpz->updateevent, sizeof(rpz->updateevent), 0, NULL, 0, - NULL, NULL, NULL, NULL, NULL); + ISC_EVENT_INIT(&rpz->updateevent, sizeof(rpz->updateevent), 0, 0, NULL, + NULL, NULL, NULL, NULL); rpz->num = rpzs->p.num_zones++; rpzs->zones[rpz->num] = rpz; @@ -1609,11 +1609,10 @@ dns_rpz_dbupdate_callback(dns_db_t *db, void *fn_arg) { dns_db_currentversion(rpz->db, &rpz->dbversion); INSIST(!ISC_LINK_LINKED(&rpz->updateevent, ev_link)); - ISC_EVENT_INIT(&rpz->updateevent, - sizeof(rpz->updateevent), 0, NULL, - DNS_EVENT_RPZUPDATED, - dns_rpz_update_taskaction, rpz, rpz, - NULL, NULL); + ISC_EVENT_INIT( + &rpz->updateevent, sizeof(rpz->updateevent), 0, + DNS_EVENT_RPZUPDATED, dns_rpz_update_taskaction, + rpz, rpz, NULL, NULL); event = &rpz->updateevent; isc_task_send(rpz->rpzs->updater, &event); } @@ -1696,8 +1695,8 @@ update_rpz_done_cb(void *data, isc_result_t result) { isc_event_t *event = NULL; INSIST(!ISC_LINK_LINKED(&rpz->updateevent, ev_link)); ISC_EVENT_INIT(&rpz->updateevent, sizeof(rpz->updateevent), 0, - NULL, DNS_EVENT_RPZUPDATED, - dns_rpz_update_taskaction, rpz, rpz, NULL, NULL); + DNS_EVENT_RPZUPDATED, dns_rpz_update_taskaction, + rpz, rpz, NULL, NULL); event = &rpz->updateevent; isc_task_send(rpz->rpzs->updater, &event); } diff --git a/lib/dns/zone.c b/lib/dns/zone.c index 600fad94e50..4cc012cf88e 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -1211,7 +1211,7 @@ dns_zone_create(dns_zone_t **zonep, isc_mem_t *mctx, unsigned int tid) { /* Must be after magic is set. */ dns_zone_setdbtype(zone, dbargc_default, dbargv_default); - ISC_EVENT_INIT(&zone->ctlevent, sizeof(zone->ctlevent), 0, NULL, + ISC_EVENT_INIT(&zone->ctlevent, sizeof(zone->ctlevent), 0, DNS_EVENT_ZONECONTROL, zone_shutdown, zone, zone, NULL, NULL); *zonep = zone; diff --git a/lib/isc/event.c b/lib/isc/event.c index 294da352548..cf5bdee5583 100644 --- a/lib/isc/event.c +++ b/lib/isc/event.c @@ -41,8 +41,8 @@ isc__event_allocate(isc_mem_t *mctx, void *sender, isc_eventtype_t type, event = isc_mem_get(mctx, size); - ISC_EVENT_INIT_PASS(event, size, 0, NULL, type, action, arg, sender, - destroy, mctx); + ISC_EVENT_INIT_PASS(event, size, 0, type, action, arg, sender, destroy, + mctx); return (event); } diff --git a/lib/isc/include/isc/event.h b/lib/isc/include/isc/event.h index c3db5406486..b7a8be35f0c 100644 --- a/lib/isc/include/isc/event.h +++ b/lib/isc/include/isc/event.h @@ -35,7 +35,6 @@ typedef void (*isc_eventdestructor_t)(isc_event_t *); #define ISC_EVENT_COMMON(ltype) \ size_t ev_size; \ unsigned int ev_attributes; \ - void *ev_tag; \ isc_eventtype_t ev_type; \ isc_taskaction_t ev_action; \ void *ev_arg; \ @@ -50,32 +49,30 @@ typedef void (*isc_eventdestructor_t)(isc_event_t *); ISC_LINK(ltype) ev_link; \ ISC_LINK(ltype) ev_ratelink -#define ISC_EVENT_INIT(event, sz, at, ta, ty, ac, ar, sn, df, da) \ - ISC__EVENT_INIT(event, sz, at, ta, ty, ac, ar, sn, df, da, __func__, \ +#define ISC_EVENT_INIT(event, sz, at, ty, ac, ar, sn, df, da) \ + ISC__EVENT_INIT(event, sz, at, ty, ac, ar, sn, df, da, __func__, \ __FILE__, __LINE__) -#define ISC_EVENT_INIT_PASS(event, sz, at, ta, ty, ac, ar, sn, df, da) \ - ISC__EVENT_INIT(event, sz, at, ta, ty, ac, ar, sn, df, da, func, file, \ - line) - -#define ISC__EVENT_INIT(event, sz, at, ta, ty, ac, ar, sn, df, da, fn, fl, ln) \ - { \ - (event)->ev_size = (sz); \ - (event)->ev_attributes = (at); \ - (event)->ev_tag = (ta); \ - (event)->ev_type = (ty); \ - (event)->ev_action = (ac); \ - (event)->ev_arg = (ar); \ - (event)->ev_sender = (sn); \ - (event)->ev_destroy = (df); \ - (event)->ev_destroy_arg = (da); \ - ISC_LINK_INIT((event), ev_link); \ - ISC_LINK_INIT((event), ev_ratelink); \ - strlcpy((event)->func, fn, sizeof((event)->func)); \ - strlcpy((event)->file, fl, sizeof((event)->file)); \ - (event)->line = ln; \ - (event)->backtrace_size = isc_backtrace( \ - (event)->backtrace, ISC__EVENT_TRACE_SIZE); \ +#define ISC_EVENT_INIT_PASS(event, sz, at, ty, ac, ar, sn, df, da) \ + ISC__EVENT_INIT(event, sz, at, ty, ac, ar, sn, df, da, func, file, line) + +#define ISC__EVENT_INIT(event, sz, at, ty, ac, ar, sn, df, da, fn, fl, ln) \ + { \ + (event)->ev_size = (sz); \ + (event)->ev_attributes = (at); \ + (event)->ev_type = (ty); \ + (event)->ev_action = (ac); \ + (event)->ev_arg = (ar); \ + (event)->ev_sender = (sn); \ + (event)->ev_destroy = (df); \ + (event)->ev_destroy_arg = (da); \ + ISC_LINK_INIT((event), ev_link); \ + ISC_LINK_INIT((event), ev_ratelink); \ + strlcpy((event)->func, fn, sizeof((event)->func)); \ + strlcpy((event)->file, fl, sizeof((event)->file)); \ + (event)->line = ln; \ + (event)->backtrace_size = isc_backtrace( \ + (event)->backtrace, ISC__EVENT_TRACE_SIZE); \ } #else @@ -86,7 +83,6 @@ typedef void (*isc_eventdestructor_t)(isc_event_t *); #define ISC_EVENT_COMMON(ltype) \ size_t ev_size; \ unsigned int ev_attributes; \ - void *ev_tag; \ isc_eventtype_t ev_type; \ isc_taskaction_t ev_action; \ void *ev_arg; \ @@ -96,19 +92,18 @@ typedef void (*isc_eventdestructor_t)(isc_event_t *); ISC_LINK(ltype) ev_link; \ ISC_LINK(ltype) ev_ratelink -#define ISC_EVENT_INIT(event, sz, at, ta, ty, ac, ar, sn, df, da) \ - { \ - (event)->ev_size = (sz); \ - (event)->ev_attributes = (at); \ - (event)->ev_tag = (ta); \ - (event)->ev_type = (ty); \ - (event)->ev_action = (ac); \ - (event)->ev_arg = (ar); \ - (event)->ev_sender = (sn); \ - (event)->ev_destroy = (df); \ - (event)->ev_destroy_arg = (da); \ - ISC_LINK_INIT((event), ev_link); \ - ISC_LINK_INIT((event), ev_ratelink); \ +#define ISC_EVENT_INIT(event, sz, at, ty, ac, ar, sn, df, da) \ + { \ + (event)->ev_size = (sz); \ + (event)->ev_attributes = (at); \ + (event)->ev_type = (ty); \ + (event)->ev_action = (ac); \ + (event)->ev_arg = (ar); \ + (event)->ev_sender = (sn); \ + (event)->ev_destroy = (df); \ + (event)->ev_destroy_arg = (da); \ + ISC_LINK_INIT((event), ev_link); \ + ISC_LINK_INIT((event), ev_ratelink); \ } #define ISC_EVENT_INIT_PASS ISC_EVENT_INIT diff --git a/lib/isc/ratelimiter.c b/lib/isc/ratelimiter.c index 4a6bc909c74..13876172055 100644 --- a/lib/isc/ratelimiter.c +++ b/lib/isc/ratelimiter.c @@ -81,7 +81,7 @@ isc_ratelimiter_create(isc_mem_t *mctx, isc_timermgr_t *timermgr, */ isc_refcount_increment(&rl->references); - ISC_EVENT_INIT(&rl->shutdownevent, sizeof(isc_event_t), 0, NULL, + ISC_EVENT_INIT(&rl->shutdownevent, sizeof(isc_event_t), 0, ISC_RATELIMITEREVENT_SHUTDOWN, ratelimiter_shutdowncomplete, rl, rl, NULL, NULL);