* zones.
*/
isc_refcount_increment(&zl->refs, NULL);
- CHECK(dns_view_asyncload(view, view_loaded, zl));
+ CHECK(dns_view_asyncload2(view, view_loaded, zl, reconfig));
}
cleanup:
isc_result_t
dns_view_asyncload(dns_view_t *view, dns_zt_allloaded_t callback, void *arg);
+
+isc_result_t
+dns_view_asyncload2(dns_view_t *view, dns_zt_allloaded_t callback, void *arg,
+ bool newonly);
/*%<
* Load zones attached to this view. dns_view_load() loads
* all zones whose master file has changed since the last
isc_result_t
dns_zone_asyncload(dns_zone_t *zone, dns_zt_zoneloaded_t done, void *arg);
+
+isc_result_t
+dns_zone_asyncload2(dns_zone_t *zone, dns_zt_zoneloaded_t done, void *arg,
+ bool newonly);
/*%<
* Cause the database to be loaded from its backing store asynchronously.
* Other zone maintenance functions are suspended until this is complete.
isc_result_t
dns_zt_asyncload(dns_zt_t *zt, dns_zt_allloaded_t alldone, void *arg);
+
+isc_result_t
+dns_zt_asyncload2(dns_zt_t *zt, dns_zt_allloaded_t alldone, void *arg,
+ bool newonly);
/*%<
* Load all zones in the table. If 'stop' is true,
* stop on the first error and return it. If 'stop'
struct args {
void *arg1;
void *arg2;
+ bool arg3;
};
/*
UNUSED(task);
- dns_zt_asyncload(args->arg1, all_done, args->arg2);
+ dns_zt_asyncload2(args->arg1, all_done, args->arg2, false);
isc_event_free(&event);
}
UNUSED(task);
- dns_zone_asyncload(args->arg1, load_done, args->arg2);
+ dns_zone_asyncload2(args->arg1, load_done, args->arg2, args->arg3);
isc_event_free(&event);
}
}
ATF_TC_BODY(asyncload_zone, tc) {
isc_result_t result;
+ int n;
dns_zone_t *zone = NULL;
dns_view_t *view = NULL;
dns_db_t *db = NULL;
+ FILE* zonefile, *origfile;
+ char buf[4096];
bool done = false;
int i = 0;
struct args args;
ATF_CHECK(!dns__zone_loadpending(zone));
ATF_CHECK(!done);
- dns_zone_setfile(zone, "testdata/zt/zone1.db");
+ zonefile = fopen("./zone.data", "wb");
+ ATF_CHECK(zonefile != NULL);
+ origfile = fopen("./testdata/zt/zone1.db", "r+b");
+ ATF_CHECK(origfile != NULL);
+ n = fread(buf, 1, 4096, origfile);
+ fwrite(buf, 1, n, zonefile);
+ fflush(zonefile);
+
+ dns_zone_setfile(zone, "./zone.data");
args.arg1 = zone;
args.arg2 = &done;
+ args.arg3 = false;
isc_app_onrun(mctx, maintask, start_zone_asyncload, &args);
isc_app_run();
while (dns__zone_loadpending(zone) && i++ < 5000)
dns_test_nap(1000);
ATF_CHECK(done);
+ /* The zone should now be loaded; test it */
+ result = dns_zone_getdb(zone, &db);
+ ATF_CHECK_EQ(result, ISC_R_SUCCESS);
+ dns_db_detach(&db);
+ /*
+ * Add something to zone file, reload zone with newonly - it should
+ * not be reloaded.
+ */
+ fprintf(zonefile, "\nb in b 1.2.3.4\n");
+ fflush(zonefile);
+
+ args.arg1 = zone;
+ args.arg2 = &done;
+ args.arg3 = false;
+ isc_app_onrun(mctx, maintask, start_zone_asyncload, &args);
+
+ isc_app_run();
+ while (dns__zone_loadpending(zone) && i++ < 5000)
+ dns_test_nap(1000);
+ ATF_CHECK(done);
/* The zone should now be loaded; test it */
result = dns_zone_getdb(zone, &db);
ATF_CHECK_EQ(result, ISC_R_SUCCESS);
+ dns_db_detach(&db);
+
+ /* Now reload it without newonly - it should be reloaded */
+ args.arg1 = zone;
+ args.arg2 = &done;
+ args.arg3 = false;
+ isc_app_onrun(mctx, maintask, start_zone_asyncload, &args);
+
+ isc_app_run();
+
+ while (dns__zone_loadpending(zone) && i++ < 5000)
+ dns_test_nap(1000);
+ ATF_CHECK(done);
+ /* The zone should now be loaded; test it */
+ result = dns_zone_getdb(zone, &db);
+ ATF_CHECK_EQ(result, ISC_R_SUCCESS);
+
ATF_CHECK(db != NULL);
if (db != NULL)
dns_db_detach(&db);
isc_result_t
dns_view_asyncload(dns_view_t *view, dns_zt_allloaded_t callback, void *arg) {
+ return (dns_view_asyncload2(view, callback, arg, false));
+}
+
+isc_result_t
+dns_view_asyncload2(dns_view_t *view, dns_zt_allloaded_t callback, void *arg,
+ bool newonly) {
REQUIRE(DNS_VIEW_VALID(view));
REQUIRE(view->zonetable != NULL);
- return (dns_zt_asyncload(view->zonetable, callback, arg));
+ return (dns_zt_asyncload2(view->zonetable, callback, arg, newonly));
}
isc_result_t
dns_view_adddelegationonly
dns_view_addzone
dns_view_asyncload
+dns_view_asyncload2
dns_view_attach
dns_view_checksig
dns_view_create
dns_xfrin_shutdown
dns_zone_addnsec3chain
dns_zone_asyncload
+dns_zone_asyncload2
dns_zone_attach
dns_zone_catz_enable
dns_zone_catz_enable_db
dns_zt_apply
dns_zt_apply2
dns_zt_asyncload
+dns_zt_asyncload2
dns_zt_attach
dns_zt_create
dns_zt_detach
dns_zone_t *zone;
dns_zt_zoneloaded_t loaded;
void *loaded_arg;
+ bool newonly;
};
/*%
isc_event_free(&event);
LOCK_ZONE(zone);
- result = zone_load(zone, 0, true);
+ result = zone_load(zone, asl->newonly ? DNS_ZONELOADFLAG_NOSTAT : 0,
+ true);
if (result != DNS_R_CONTINUE) {
DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_LOADPENDING);
}
isc_result_t
dns_zone_asyncload(dns_zone_t *zone, dns_zt_zoneloaded_t done, void *arg) {
+ return (dns_zone_asyncload2(zone, done, arg, false));
+}
+
+isc_result_t
+dns_zone_asyncload2(dns_zone_t *zone, dns_zt_zoneloaded_t done, void * arg,
+ bool newonly)
+{
isc_event_t *e;
dns_asyncload_t *asl = NULL;
isc_result_t result = ISC_R_SUCCESS;
asl->zone = NULL;
asl->loaded = done;
asl->loaded_arg = arg;
+ asl->newonly = newonly;
e = isc_event_allocate(zone->zmgr->mctx, zone->zmgr,
DNS_EVENT_ZONELOAD,
#define ZTMAGIC ISC_MAGIC('Z', 'T', 'b', 'l')
#define VALID_ZT(zt) ISC_MAGIC_VALID(zt, ZTMAGIC)
+struct zt_load_params {
+ dns_zt_zoneloaded_t dl;
+ bool newonly;
+ struct dns_zt* zt;
+};
+
static void
auto_detach(void *, void *);
isc_result_t
dns_zt_asyncload(dns_zt_t *zt, dns_zt_allloaded_t alldone, void *arg) {
+ return (dns_zt_asyncload2(zt, alldone, arg, false));
+}
+
+isc_result_t
+dns_zt_asyncload2(dns_zt_t *zt, dns_zt_allloaded_t alldone, void *arg,
+ bool newonly)
+{
isc_result_t result;
- static dns_zt_zoneloaded_t dl = doneloading;
+ struct zt_load_params params;
+ params.dl = doneloading;
+ params.newonly = newonly;
+ params.zt = zt;
int pending;
REQUIRE(VALID_ZT(zt));
RWLOCK(&zt->rwlock, isc_rwlocktype_write);
INSIST(zt->loads_pending == 0);
- result = dns_zt_apply2(zt, false, NULL, asyncload, &dl);
+ result = dns_zt_apply2(zt, false, NULL, asyncload, ¶ms);
pending = zt->loads_pending;
if (pending != 0) {
* the zone loading is complete.
*/
static isc_result_t
-asyncload(dns_zone_t *zone, void *callback) {
+asyncload(dns_zone_t *zone, void *paramsv) {
isc_result_t result;
- dns_zt_zoneloaded_t *loaded = callback;
- dns_zt_t *zt;
+ struct zt_load_params * params = (struct zt_load_params*) paramsv;
+
+ dns_zt_t *zt = params->zt;
REQUIRE(zone != NULL);
zt = dns_zone_getview(zone)->zonetable;
zt->references++;
zt->loads_pending++;
- result = dns_zone_asyncload(zone, *loaded, zt);
+ result = dns_zone_asyncload2(zone, *params->dl, zt, params->newonly);
if (result != ISC_R_SUCCESS) {
zt->references--;
zt->loads_pending--;