diff --git a/bin/named/server.c b/bin/named/server.c index bebd2b50b7..e785b71681 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -551,24 +551,6 @@ load_configuration(const char *filename, ns_server_t *server) { } } - /* - * Load zones. - */ - for (view = ISC_LIST_HEAD(lctx.viewlist); - view != NULL; - view = view_next) { - view_next = ISC_LIST_NEXT(view, link); - /* XXX error checking */ - dns_view_load(view); - } - - /* - * Force zone maintenance. Do this after loading - * so that we know when we need to force AXFR of - * slave zones whose master files are missing. - */ - CHECK(dns_zonemgr_forcemaint(server->zonemgr)); - /* * Swap our new view list with the production one. */ @@ -611,6 +593,31 @@ load_configuration(const char *filename, ns_server_t *server) { return (result); } +static isc_result_t +load_zones(ns_server_t *server, isc_boolean_t stop) { + isc_result_t result; + dns_view_t *view; + + /* + * Load zone data from disk. + */ + for (view = ISC_LIST_HEAD(server->viewlist); + view != NULL; + view = ISC_LIST_NEXT(view, link)) + { + CHECK(dns_view_load(view, stop)); + } + + /* + * Force zone maintenance. Do this after loading + * so that we know when we need to force AXFR of + * slave zones whose master files are missing. + */ + CHECK(dns_zonemgr_forcemaint(server->zonemgr)); + cleanup: + return (result); +} + static void run_server(isc_task_t *task, isc_event_t *event) { isc_result_t result; @@ -631,6 +638,9 @@ run_server(isc_task_t *task, isc_event_t *event) { CHECKFATAL(load_configuration(ns_g_conffile, server), "loading configuration"); + CHECKFATAL(load_zones(server, ISC_TRUE), + "loading zones"); + isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER, ISC_LOG_INFO, "running"); } diff --git a/lib/dns/include/dns/view.h b/lib/dns/include/dns/view.h index 140b22a405..5603c5c479 100644 --- a/lib/dns/include/dns/view.h +++ b/lib/dns/include/dns/view.h @@ -433,10 +433,12 @@ dns_view_findzone(dns_view_t *view, dns_name_t *name, dns_zone_t **zone); * XXX */ -void -dns_view_load(dns_view_t *view); +isc_result_t +dns_view_load(dns_view_t *view, isc_boolean_t stop); /* - * Load all zones attached to this view. + * Load all zones attached to this view. If 'stop' is ISC_TRUE, + * stop on the first error and return it. If 'stop' + * is ISC_FALSE, ignore errors. * * Requires: * diff --git a/lib/dns/include/dns/zt.h b/lib/dns/include/dns/zt.h index 9ae28f7dd7..a5b11c2c6b 100644 --- a/lib/dns/include/dns/zt.h +++ b/lib/dns/include/dns/zt.h @@ -112,10 +112,12 @@ void dns_zt_attach(dns_zt_t *zt, dns_zt_t **ztp); * '*ztp' to be NULL */ -void dns_zt_load(dns_zt_t *zt); +isc_result_t dns_zt_load(dns_zt_t *zt, isc_boolean_t stop); /* - * Load all zones in the table. + * Load all zones in the table. If 'stop' is ISC_TRUE, + * stop on the first error and return it. If 'stop' + * is ISC_FALSE, ignore errors. * * Requires: * 'zt' to be valid diff --git a/lib/dns/view.c b/lib/dns/view.c index 27459ee221..3be3a5c63a 100644 --- a/lib/dns/view.c +++ b/lib/dns/view.c @@ -798,12 +798,12 @@ dns_viewlist_find(dns_viewlist_t *list, const char *name, return (ISC_R_SUCCESS); } -void -dns_view_load(dns_view_t *view) { +isc_result_t +dns_view_load(dns_view_t *view, isc_boolean_t stop) { REQUIRE(DNS_VIEW_VALID(view)); - dns_zt_load(view->zonetable); + return (dns_zt_load(view->zonetable, stop)); } isc_result_t diff --git a/lib/dns/zt.c b/lib/dns/zt.c index 361199fed3..6b726d4405 100644 --- a/lib/dns/zt.c +++ b/lib/dns/zt.c @@ -217,9 +217,9 @@ dns_zt_print(dns_zt_t *zt) { RWUNLOCK(&zt->rwlock, isc_rwlocktype_read); } -void -dns_zt_load(dns_zt_t *zt) { - (void)dns_zt_apply(zt, ISC_FALSE, load, NULL); +isc_result_t +dns_zt_load(dns_zt_t *zt, isc_boolean_t stop) { + return (dns_zt_apply(zt, stop, load, NULL)); } static isc_result_t