if (result == ISC_R_SUCCESS && strcmp(view->name, "_bind") != 0)
{
dns_view_setviewrevert(view);
- (void)dns_zt_apply(view->zonetable, false, NULL,
- removed, view);
+ (void)dns_view_apply(view, false, NULL, removed, view);
}
dns_view_detach(&view);
}
ISC_LIST_INIT(vle->zonelist);
ISC_LIST_APPEND(dctx->viewlist, vle, link);
if (dctx->dumpzones) {
- result = dns_zt_apply(view->zonetable, true, NULL,
- add_zone_tolist, dctx);
+ result = dns_view_apply(view, true, NULL, add_zone_tolist,
+ dctx);
}
return (result);
}
for (view = ISC_LIST_HEAD(server->viewlist); view != NULL;
view = ISC_LIST_NEXT(view, link))
{
- result = dns_zt_apply(view->zonetable, false, NULL,
- synczone, &cleanup);
+ result = dns_view_apply(view, false, NULL, synczone,
+ &cleanup);
if (result != ISC_R_SUCCESS && tresult == ISC_R_SUCCESS)
{
tresult = result;
if ((flags & STATS_XML_ZONES) != 0) {
TRY0(xmlTextWriterStartElement(writer,
ISC_XMLCHAR "zones"));
- CHECK(dns_zt_apply(view->zonetable, true, NULL,
- zone_xmlrender, writer));
+ CHECK(dns_view_apply(view, true, NULL, zone_xmlrender,
+ writer));
TRY0(xmlTextWriterEndElement(writer)); /* /zones */
}
CHECKMEM(za);
if ((flags & STATS_JSON_ZONES) != 0) {
- CHECK(dns_zt_apply(view->zonetable, true, NULL,
- zone_jsonrender, za));
+ CHECK(dns_view_apply(view, true, NULL,
+ zone_jsonrender, za));
}
if (json_object_array_length(za) != 0) {
*
*\li Anything else Failure.
*/
+
+isc_result_t
+dns_view_apply(dns_view_t *view, bool stop, isc_result_t *sub,
+ isc_result_t (*action)(dns_zone_t *, void *), void *uap);
+/*%<
+ * Call dns_zt_apply on the view's zonetable.
+ *
+ * Returns:
+ * \li ISC_R_SUCCESS if action was applied to all nodes. If 'stop' is
+ * false and 'sub' is non NULL then the first error (if any)
+ * reported by 'action' is returned in '*sub'. If 'stop' is true,
+ * the first error code from 'action' is returned.
+ *
+ * \li ISC_R_SHUTTINGDOWN if the view is in the process of shutting down.
+ */
+
ISC_LANG_ENDDECLS
cleanup:
return (result);
}
+
+isc_result_t
+dns_view_apply(dns_view_t *view, bool stop, isc_result_t *sub,
+ isc_result_t (*action)(dns_zone_t *, void *), void *uap) {
+ isc_result_t result;
+ dns_zt_t *zonetable = NULL;
+
+ REQUIRE(DNS_VIEW_VALID(view));
+
+ rcu_read_lock();
+ zonetable = rcu_dereference(view->zonetable);
+ if (zonetable != NULL) {
+ result = dns_zt_apply(zonetable, stop, sub, action, uap);
+ } else {
+ result = ISC_R_SHUTTINGDOWN;
+ }
+ rcu_read_unlock();
+ return (result);
+}
assert_non_null(zt);
assert_int_equal(nzones, 0);
- result = dns_zt_apply(view->zonetable, false, NULL, count_zone,
- &nzones);
+ result = dns_view_apply(view, false, NULL, count_zone, &nzones);
assert_int_equal(result, ISC_R_SUCCESS);
assert_int_equal(nzones, 1);