Commit ff8ab6be authored by Mark Andrews's avatar Mark Andrews
Browse files

redo: 3576. [bug] Address a shutdown race when validating. [RT #33573]

parent 85d259b3
......@@ -3713,7 +3713,7 @@ dns_validator_create(dns_view_t *view, dns_name_t *name, dns_rdatatype_t type,
if (val == NULL)
return (ISC_R_NOMEMORY);
val->view = NULL;
dns_view_attach(view, &val->view);
dns_view_weakattach(view, &val->view);
event = (dns_validatorevent_t *)
isc_event_allocate(view->mctx, task,
......@@ -3789,7 +3789,7 @@ dns_validator_create(dns_view_t *view, dns_name_t *name, dns_rdatatype_t type,
isc_event_free(ISC_EVENT_PTR(&event));
cleanup_val:
dns_view_detach(&val->view);
dns_view_weakdetach(&val->view);
isc_mem_put(view->mctx, val, sizeof(*val));
return (result);
......@@ -3869,7 +3869,7 @@ destroy(dns_validator_t *val) {
if (val->siginfo != NULL)
isc_mem_put(mctx, val->siginfo, sizeof(*val->siginfo));
DESTROYLOCK(&val->lock);
dns_view_detach(&val->view);
dns_view_weakdetach(&val->view);
val->magic = 0;
isc_mem_put(mctx, val, sizeof(*val));
}
......
......@@ -561,8 +561,9 @@ dialup(dns_zone_t *zone, void *dummy) {
void
dns_view_dialup(dns_view_t *view) {
REQUIRE(DNS_VIEW_VALID(view));
if (view->zonetable != NULL)
(void)dns_zt_apply(view->zonetable, ISC_FALSE, dialup, NULL);
REQUIRE(view->zonetable != NULL);
(void)dns_zt_apply(view->zonetable, ISC_FALSE, dialup, NULL);
}
void
......@@ -887,6 +888,7 @@ dns_view_findzone(dns_view_t *view, dns_name_t *name, dns_zone_t **zonep) {
REQUIRE(DNS_VIEW_VALID(view));
LOCK(&view->lock);
if (view->zonetable != NULL) {
result = dns_zt_find(view->zonetable, name, 0, NULL, zonep);
if (result == DNS_R_PARTIALMATCH) {
......@@ -895,6 +897,7 @@ dns_view_findzone(dns_view_t *view, dns_name_t *name, dns_zone_t **zonep) {
}
} else
result = ISC_R_NOTFOUND;
UNLOCK(&view->lock);
return (result);
}
......@@ -949,12 +952,14 @@ dns_view_find2(dns_view_t *view, dns_name_t *name, dns_rdatatype_t type,
node = NULL;
is_staticstub_zone = ISC_FALSE;
zone = NULL;
if (view->zonetable != NULL) {
LOCK(&view->lock);
if (view->zonetable != NULL)
result = dns_zt_find(view->zonetable, name, 0, NULL, &zone);
if (zone != NULL && !use_static_stub &&
dns_zone_gettype(zone) == dns_zone_staticstub)
result = ISC_R_NOTFOUND;
} else
else
result = ISC_R_NOTFOUND;
UNLOCK(&view->lock);
if (zone != NULL && dns_zone_gettype(zone) == dns_zone_staticstub &&
!use_static_stub)
result = ISC_R_NOTFOUND;
if (result == ISC_R_SUCCESS || result == DNS_R_PARTIALMATCH) {
result = dns_zone_getdb(zone, &db);
......@@ -1208,10 +1213,12 @@ dns_view_findzonecut2(dns_view_t *view, dns_name_t *name, dns_name_t *fname,
* Find the right database.
*/
zone = NULL;
LOCK(&view->lock);
if (view->zonetable != NULL)
result = dns_zt_find(view->zonetable, name, 0, NULL, &zone);
else
result = ISC_R_NOTFOUND;
UNLOCK(&view->lock);
if (result == ISC_R_SUCCESS || result == DNS_R_PARTIALMATCH)
result = dns_zone_getdb(zone, &db);
if (result == ISC_R_NOTFOUND) {
......@@ -1397,11 +1404,13 @@ dns_viewlist_findzone(dns_viewlist_t *list, dns_name_t *name,
* treat it as not found.
*/
zp = (zone1 == NULL) ? &zone1 : &zone2;
LOCK(&view->lock);
if (view->zonetable != NULL)
result = dns_zt_find(view->zonetable, name, 0, NULL,
zp);
result = dns_zt_find(view->zonetable, name, 0,
NULL, zp);
else
result = ISC_R_NOTFOUND;
UNLOCK(&view->lock);
INSIST(result == ISC_R_SUCCESS ||
result == ISC_R_NOTFOUND ||
result == DNS_R_PARTIALMATCH);
......@@ -1682,6 +1691,7 @@ dns_view_getrootdelonly(dns_view_t *view) {
isc_result_t
dns_view_freezezones(dns_view_t *view, isc_boolean_t value) {
REQUIRE(DNS_VIEW_VALID(view));
REQUIRE(view->zonetable != NULL);
......@@ -1708,6 +1718,7 @@ dns_view_getadbstats(dns_view_t *view, isc_stats_t **statsp) {
void
dns_view_setresstats(dns_view_t *view, isc_stats_t *stats) {
REQUIRE(DNS_VIEW_VALID(view));
REQUIRE(!view->frozen);
REQUIRE(view->resstats == NULL);
......
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