Simplify the isc_event API

The ev_tag field was never used, and has now been removed.
This commit is contained in:
Ondřej Surý 2022-07-26 13:03:01 +02:00
parent 87a6dac92e
commit a26862e653
No known key found for this signature in database
GPG key ID: 2820F37E873DEA41
8 changed files with 49 additions and 55 deletions

View file

@ -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;

View file

@ -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);

View file

@ -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);

View file

@ -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);
}

View file

@ -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;

View file

@ -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);
}

View file

@ -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_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, 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(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

View file

@ -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);