Commit 67562802 authored by Matthijs Mekking's avatar Matthijs Mekking 🏡 Committed by Matthijs Mekking
Browse files

Remove rpz->db_registered

As pointed out in !813 db_registered is sort of redundant.  It is
set to `true` only in `dns_zone_rpz_enable_db()` right before the
`dns_rpz_dbupdate_callback()` callback is registered.  It is only
required in that callback and it is the only place that the callback
is registered.  Therefore there is no path that that `REQUIRE` can
fail.

The `db_registered` variable is only set to `false` in
`dns_rpz_new_zone`, so it is not like the variable is unset again
later.

The only other place where `db_registered` is checked is in
`rpz_detach()`.  If `true`, it will call
`dns_db_updatenotify_unregister()`.  However if that happens, the
`db_registered` is not set back to `false` thus this implies that
this may happen multiple times.  If called a second time, most
likely the unregister function will return `ISC_R_NOTFOUND`, but
the return value is not checked anyway.  So it can do without the
`db_registered` check.
parent 2e5e4296
......@@ -144,15 +144,14 @@ struct dns_rpz_zone {
isc_ht_t *nodes; /* entries in zone */
dns_rpz_zones_t *rpzs; /* owner */
isc_time_t lastupdated; /* last time the zone was processed */
bool updatepending; /* there is an update pending/waiting */
bool updaterunning; /* there is an update running */
bool updatepending; /* there is an update pending/waiting */
bool updaterunning; /* there is an update running */
dns_db_t *db; /* zones database */
dns_dbversion_t *dbversion; /* version we will be updating to */
dns_db_t *updb; /* zones database we're working on */
dns_dbversion_t *updbversion; /* version we're currently working on */
dns_dbiterator_t *updbit; /* iterator to use when updating */
isc_ht_t *newnodes; /* entries in zone being updated */
bool db_registered; /* is the notify event registered? */
isc_timer_t *updatetimer;
isc_event_t updateevent;
};
......
......@@ -1549,7 +1549,6 @@ dns_rpz_new_zone(dns_rpz_zones_t *rpzs, dns_rpz_zone_t **rpzp) {
zone->updbversion = NULL;
zone->updbit = NULL;
zone->rpzs = rpzs;
zone->db_registered = false;
ISC_EVENT_INIT(&zone->updateevent, sizeof(zone->updateevent),
0, NULL, 0, NULL, NULL, NULL, NULL, NULL);
......@@ -1584,7 +1583,6 @@ dns_rpz_dbupdate_callback(dns_db_t *db, void *fn_arg) {
REQUIRE(zone != NULL);
LOCK(&zone->rpzs->maint_lock);
REQUIRE(zone->db_registered);
/* New zone came as AXFR */
if (zone->db != NULL && zone->db != db) {
......@@ -2100,10 +2098,8 @@ rpz_detach(dns_rpz_zone_t **rpzp, dns_rpz_zones_t *rpzs) {
dns_db_closeversion(rpz->db, &rpz->dbversion, false);
}
if (rpz->db != NULL) {
if (rpz->db_registered) {
dns_db_updatenotify_unregister(
rpz->db, dns_rpz_dbupdate_callback, rpz);
}
dns_db_updatenotify_unregister(
rpz->db, dns_rpz_dbupdate_callback, rpz);
dns_db_detach(&rpz->db);
}
if (rpz->updaterunning) {
......
......@@ -1786,7 +1786,6 @@ dns_zone_rpz_enable_db(dns_zone_t *zone, dns_db_t *db) {
if (zone->rpz_num == DNS_RPZ_INVALID_NUM)
return;
REQUIRE(zone->rpzs != NULL);
zone->rpzs->zones[zone->rpz_num]->db_registered = true;
result = dns_db_updatenotify_register(db,
dns_rpz_dbupdate_callback,
zone->rpzs->zones[zone->rpz_num]);
......
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