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

This commit is contained in:
Mark Andrews 2013-06-04 11:26:33 +10:00
parent c1322d49bc
commit 286ef95ba5
2 changed files with 31 additions and 6 deletions

View file

@ -3718,7 +3718,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,
@ -3794,7 +3794,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);
@ -3874,7 +3874,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));
}

View file

@ -560,6 +560,8 @@ dialup(dns_zone_t *zone, void *dummy) {
void
dns_view_dialup(dns_view_t *view) {
REQUIRE(DNS_VIEW_VALID(view));
REQUIRE(view->zonetable != NULL);
(void)dns_zt_apply(view->zonetable, ISC_FALSE, dialup, NULL);
}
#endif
@ -868,6 +870,7 @@ dns_view_addzone(dns_view_t *view, dns_zone_t *zone) {
REQUIRE(DNS_VIEW_VALID(view));
REQUIRE(!view->frozen);
REQUIRE(view->zonetable != NULL);
result = dns_zt_mount(view->zonetable, zone);
@ -882,6 +885,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) {
@ -890,6 +894,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);
}
@ -952,7 +957,12 @@ dns_view_find2(dns_view_t *view, dns_name_t *name, dns_rdatatype_t type,
is_staticstub_zone = ISC_FALSE;
#ifdef BIND9
zone = NULL;
result = dns_zt_find(view->zonetable, name, 0, NULL, &zone);
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 (zone != NULL && dns_zone_gettype(zone) == dns_zone_staticstub &&
!use_static_stub) {
result = ISC_R_NOTFOUND;
@ -1223,9 +1233,14 @@ dns_view_findzonecut2(dns_view_t *view, dns_name_t *name, dns_name_t *fname,
*/
#ifdef BIND9
zone = NULL;
result = dns_zt_find(view->zonetable, name, 0, NULL, &zone);
LOCK(&view->lock);
if (view->zonetable != NULL)
result = dns_zt_find(view->zonetable, name, 0, NULL, &zone);
else
result = ISC_R_NOTFOUND;
if (result == ISC_R_SUCCESS || result == DNS_R_PARTIALMATCH)
result = dns_zone_getdb(zone, &db);
UNLOCK(&view->lock);
#else
result = ISC_R_NOTFOUND;
#endif
@ -1415,7 +1430,13 @@ dns_viewlist_findzone(dns_viewlist_t *list, dns_name_t *name,
* treat it as not found.
*/
zp = (zone1 == NULL) ? &zone1 : &zone2;
result = dns_zt_find(view->zonetable, name, 0, NULL, zp);
LOCK(&view->lock);
if (view->zonetable != NULL)
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);
@ -1706,13 +1727,17 @@ dns_view_getrootdelonly(dns_view_t *view) {
#ifdef BIND9
isc_result_t
dns_view_freezezones(dns_view_t *view, isc_boolean_t value) {
REQUIRE(DNS_VIEW_VALID(view));
REQUIRE(view->zonetable != NULL);
return (dns_zt_freezezones(view->zonetable, value));
}
#endif
void
dns_view_setresstats(dns_view_t *view, isc_stats_t *stats) {
REQUIRE(DNS_VIEW_VALID(view));
REQUIRE(!view->frozen);
REQUIRE(view->resstats == NULL);