mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-01 15:05:23 +00:00
Refactor dns_master_loadfileinc() to use loopmgr instead of tasks
Incremental file loads now use loopmgr events instead of task events. The dns_master_loadstreaminc(), _loadbufferinc(), _loadlexer() and _loadlexerinc() functions were not used in BIND, and have been removed.
This commit is contained in:
@@ -46,30 +46,30 @@
|
||||
#define DNS_EVENT_NOTIFYSENDTOADDR (ISC_EVENTCLASS_DNS + 23)
|
||||
#define DNS_EVENT_ZONE (ISC_EVENTCLASS_DNS + 24)
|
||||
#define DNS_EVENT_ZONESTARTXFRIN (ISC_EVENTCLASS_DNS + 25)
|
||||
#define DNS_EVENT_MASTERQUANTUM (ISC_EVENTCLASS_DNS + 26)
|
||||
#define DNS_EVENT_CACHEOVERMEM (ISC_EVENTCLASS_DNS + 27)
|
||||
#define DNS_EVENT_MASTERNEXTZONE (ISC_EVENTCLASS_DNS + 28)
|
||||
#define DNS_EVENT_IOREADY (ISC_EVENTCLASS_DNS + 29)
|
||||
#define DNS_EVENT_LOOKUPDONE (ISC_EVENTCLASS_DNS + 30)
|
||||
#define DNS_EVENT_RBTDEADNODES (ISC_EVENTCLASS_DNS + 31)
|
||||
#define DNS_EVENT_DISPATCHCONTROL (ISC_EVENTCLASS_DNS + 32)
|
||||
#define DNS_EVENT_REQUESTCONTROL (ISC_EVENTCLASS_DNS + 33)
|
||||
#define DNS_EVENT_DUMPQUANTUM (ISC_EVENTCLASS_DNS + 34)
|
||||
/* #define DNS_EVENT_MASTERQUANTUM (ISC_EVENTCLASS_DNS + 26) */
|
||||
#define DNS_EVENT_CACHEOVERMEM (ISC_EVENTCLASS_DNS + 27)
|
||||
#define DNS_EVENT_MASTERNEXTZONE (ISC_EVENTCLASS_DNS + 28)
|
||||
#define DNS_EVENT_IOREADY (ISC_EVENTCLASS_DNS + 29)
|
||||
#define DNS_EVENT_LOOKUPDONE (ISC_EVENTCLASS_DNS + 30)
|
||||
#define DNS_EVENT_RBTDEADNODES (ISC_EVENTCLASS_DNS + 31)
|
||||
#define DNS_EVENT_DISPATCHCONTROL (ISC_EVENTCLASS_DNS + 32)
|
||||
#define DNS_EVENT_REQUESTCONTROL (ISC_EVENTCLASS_DNS + 33)
|
||||
#define DNS_EVENT_DUMPQUANTUM (ISC_EVENTCLASS_DNS + 34)
|
||||
/* #define DNS_EVENT_IMPORTRECVDONE (ISC_EVENTCLASS_DNS + 35) */
|
||||
#define DNS_EVENT_FREESTORAGE (ISC_EVENTCLASS_DNS + 36)
|
||||
/* #define DNS_EVENT_VIEWACACHESHUTDOWN (ISC_EVENTCLASS_DNS + 37) */
|
||||
#define DNS_EVENT_ACACHECONTROL (ISC_EVENTCLASS_DNS + 38)
|
||||
#define DNS_EVENT_ACACHECLEAN (ISC_EVENTCLASS_DNS + 39)
|
||||
#define DNS_EVENT_ACACHEOVERMEM (ISC_EVENTCLASS_DNS + 40)
|
||||
#define DNS_EVENT_RBTPRUNE (ISC_EVENTCLASS_DNS + 41)
|
||||
#define DNS_EVENT_MANAGEKEYS (ISC_EVENTCLASS_DNS + 42)
|
||||
#define DNS_EVENT_CLIENTRESDONE (ISC_EVENTCLASS_DNS + 43)
|
||||
#define DNS_EVENT_CLIENTREQDONE (ISC_EVENTCLASS_DNS + 44)
|
||||
#define DNS_EVENT_ADBGROWENTRIES (ISC_EVENTCLASS_DNS + 45)
|
||||
#define DNS_EVENT_ADBGROWNAMES (ISC_EVENTCLASS_DNS + 46)
|
||||
#define DNS_EVENT_ZONESECURESERIAL (ISC_EVENTCLASS_DNS + 47)
|
||||
#define DNS_EVENT_ZONESECUREDB (ISC_EVENTCLASS_DNS + 48)
|
||||
#define DNS_EVENT_ZONELOAD (ISC_EVENTCLASS_DNS + 49)
|
||||
#define DNS_EVENT_ACACHECONTROL (ISC_EVENTCLASS_DNS + 38)
|
||||
#define DNS_EVENT_ACACHECLEAN (ISC_EVENTCLASS_DNS + 39)
|
||||
#define DNS_EVENT_ACACHEOVERMEM (ISC_EVENTCLASS_DNS + 40)
|
||||
#define DNS_EVENT_RBTPRUNE (ISC_EVENTCLASS_DNS + 41)
|
||||
#define DNS_EVENT_MANAGEKEYS (ISC_EVENTCLASS_DNS + 42)
|
||||
#define DNS_EVENT_CLIENTRESDONE (ISC_EVENTCLASS_DNS + 43)
|
||||
#define DNS_EVENT_CLIENTREQDONE (ISC_EVENTCLASS_DNS + 44)
|
||||
#define DNS_EVENT_ADBGROWENTRIES (ISC_EVENTCLASS_DNS + 45)
|
||||
#define DNS_EVENT_ADBGROWNAMES (ISC_EVENTCLASS_DNS + 46)
|
||||
#define DNS_EVENT_ZONESECURESERIAL (ISC_EVENTCLASS_DNS + 47)
|
||||
#define DNS_EVENT_ZONESECUREDB (ISC_EVENTCLASS_DNS + 48)
|
||||
/* #define DNS_EVENT_ZONELOAD (ISC_EVENTCLASS_DNS + 49) */
|
||||
#define DNS_EVENT_KEYDONE (ISC_EVENTCLASS_DNS + 50)
|
||||
#define DNS_EVENT_SETNSEC3PARAM (ISC_EVENTCLASS_DNS + 51)
|
||||
#define DNS_EVENT_SETSERIAL (ISC_EVENTCLASS_DNS + 52)
|
||||
|
@@ -135,45 +135,19 @@ dns_master_loadbuffer(isc_buffer_t *buffer, dns_name_t *top, dns_name_t *origin,
|
||||
dns_rdataclass_t zclass, unsigned int options,
|
||||
dns_rdatacallbacks_t *callbacks, isc_mem_t *mctx);
|
||||
|
||||
isc_result_t
|
||||
dns_master_loadlexer(isc_lex_t *lex, dns_name_t *top, dns_name_t *origin,
|
||||
dns_rdataclass_t zclass, unsigned int options,
|
||||
dns_rdatacallbacks_t *callbacks, isc_mem_t *mctx);
|
||||
|
||||
isc_result_t
|
||||
dns_master_loadfileinc(const char *master_file, dns_name_t *top,
|
||||
dns_name_t *origin, dns_rdataclass_t zclass,
|
||||
unsigned int options, uint32_t resign,
|
||||
dns_rdatacallbacks_t *callbacks, isc_task_t *task,
|
||||
dns_rdatacallbacks_t *callbacks, isc_loop_t *loop,
|
||||
dns_loaddonefunc_t done, void *done_arg,
|
||||
dns_loadctx_t **ctxp, dns_masterincludecb_t include_cb,
|
||||
void *include_arg, isc_mem_t *mctx,
|
||||
dns_masterformat_t format, uint32_t maxttl);
|
||||
|
||||
isc_result_t
|
||||
dns_master_loadstreaminc(FILE *stream, dns_name_t *top, dns_name_t *origin,
|
||||
dns_rdataclass_t zclass, unsigned int options,
|
||||
dns_rdatacallbacks_t *callbacks, isc_task_t *task,
|
||||
dns_loaddonefunc_t done, void *done_arg,
|
||||
dns_loadctx_t **ctxp, isc_mem_t *mctx);
|
||||
|
||||
isc_result_t
|
||||
dns_master_loadbufferinc(isc_buffer_t *buffer, dns_name_t *top,
|
||||
dns_name_t *origin, dns_rdataclass_t zclass,
|
||||
unsigned int options, dns_rdatacallbacks_t *callbacks,
|
||||
isc_task_t *task, dns_loaddonefunc_t done,
|
||||
void *done_arg, dns_loadctx_t **ctxp, isc_mem_t *mctx);
|
||||
|
||||
isc_result_t
|
||||
dns_master_loadlexerinc(isc_lex_t *lex, dns_name_t *top, dns_name_t *origin,
|
||||
dns_rdataclass_t zclass, unsigned int options,
|
||||
dns_rdatacallbacks_t *callbacks, isc_task_t *task,
|
||||
dns_loaddonefunc_t done, void *done_arg,
|
||||
dns_loadctx_t **ctxp, isc_mem_t *mctx);
|
||||
|
||||
/*%<
|
||||
* Loads a RFC1305 master file from a file, stream, buffer, or existing
|
||||
* lexer into rdatasets and then calls 'callbacks->commit' to commit the
|
||||
* Loads a RFC1305 master file from a file, stream, or buffer
|
||||
* into rdatasets and then calls 'callbacks->commit' to commit the
|
||||
* rdatasets. Rdata memory belongs to dns_master_load and will be
|
||||
* reused / released when the callback completes. dns_load_master will
|
||||
* abort if callbacks->commit returns any value other than ISC_R_SUCCESS.
|
||||
@@ -193,14 +167,13 @@ dns_master_loadlexerinc(isc_lex_t *lex, dns_name_t *top, dns_name_t *origin,
|
||||
*
|
||||
* Requires:
|
||||
*\li 'master_file' points to a valid string.
|
||||
*\li 'lexer' points to a valid lexer.
|
||||
*\li 'top' points to a valid name.
|
||||
*\li 'origin' points to a valid name.
|
||||
*\li 'callbacks->commit' points to a valid function.
|
||||
*\li 'callbacks->error' points to a valid function.
|
||||
*\li 'callbacks->warn' points to a valid function.
|
||||
*\li 'mctx' points to a valid memory context.
|
||||
*\li 'task' and 'done' to be valid.
|
||||
*\li 'loop' and 'done' to be valid.
|
||||
*\li 'lmgr' to be valid.
|
||||
*\li 'ctxp != NULL && ctxp == NULL'.
|
||||
*
|
||||
@@ -215,7 +188,7 @@ dns_master_loadlexerinc(isc_lex_t *lex, dns_name_t *top, dns_name_t *origin,
|
||||
*\li DNS_R_NOOWNER failed to specify a ownername.
|
||||
*\li DNS_R_NOTTL failed to specify a ttl.
|
||||
*\li DNS_R_BADCLASS record class did not match zone class.
|
||||
*\li DNS_R_CONTINUE load still in progress (dns_master_load*inc() only).
|
||||
*\li DNS_R_CONTINUE load still in progress (dns_master_loadfileinc() only).
|
||||
*\li Any dns_rdata_fromtext() error code.
|
||||
*\li Any error code from callbacks->commit().
|
||||
*/
|
||||
|
250
lib/dns/master.c
250
lib/dns/master.c
@@ -16,9 +16,11 @@
|
||||
#include <inttypes.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <isc/async.h>
|
||||
#include <isc/atomic.h>
|
||||
#include <isc/event.h>
|
||||
#include <isc/lex.h>
|
||||
#include <isc/loop.h>
|
||||
#include <isc/magic.h>
|
||||
#include <isc/mem.h>
|
||||
#include <isc/print.h>
|
||||
@@ -28,7 +30,6 @@
|
||||
#include <isc/stdio.h>
|
||||
#include <isc/stdtime.h>
|
||||
#include <isc/string.h>
|
||||
#include <isc/task.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
#include <dns/callbacks.h>
|
||||
@@ -104,7 +105,7 @@ struct dns_loadctx {
|
||||
dns_masterformat_t format;
|
||||
|
||||
dns_rdatacallbacks_t *callbacks;
|
||||
isc_task_t *task;
|
||||
isc_loop_t *loop;
|
||||
dns_loaddonefunc_t done;
|
||||
void *done_arg;
|
||||
|
||||
@@ -206,10 +207,7 @@ grow_rdata(int, dns_rdata_t *, int, rdatalist_head_t *, rdatalist_head_t *,
|
||||
isc_mem_t *);
|
||||
|
||||
static void
|
||||
load_quantum(isc_task_t *task, isc_event_t *event);
|
||||
|
||||
static isc_result_t
|
||||
task_send(dns_loadctx_t *lctx);
|
||||
load_quantum(void *arg);
|
||||
|
||||
static void
|
||||
loadctx_destroy(dns_loadctx_t *lctx);
|
||||
@@ -455,8 +453,8 @@ loadctx_destroy(dns_loadctx_t *lctx) {
|
||||
isc_lex_destroy(&lctx->lex);
|
||||
}
|
||||
|
||||
if (lctx->task != NULL) {
|
||||
isc_task_detach(&lctx->task);
|
||||
if (lctx->loop != NULL) {
|
||||
isc_loop_detach(&lctx->loop);
|
||||
}
|
||||
|
||||
isc_mem_putanddetach(&lctx->mctx, lctx, sizeof(*lctx));
|
||||
@@ -499,10 +497,10 @@ static isc_result_t
|
||||
loadctx_create(dns_masterformat_t format, isc_mem_t *mctx, unsigned int options,
|
||||
uint32_t resign, dns_name_t *top, dns_rdataclass_t zclass,
|
||||
dns_name_t *origin, dns_rdatacallbacks_t *callbacks,
|
||||
isc_task_t *task, dns_loaddonefunc_t done, void *done_arg,
|
||||
isc_loop_t *loop, dns_loaddonefunc_t done, void *done_arg,
|
||||
dns_masterincludecb_t include_cb, void *include_arg,
|
||||
isc_lex_t *lex, dns_loadctx_t **lctxp) {
|
||||
dns_loadctx_t *lctx;
|
||||
dns_loadctx_t *lctx = NULL;
|
||||
isc_result_t result;
|
||||
isc_region_t r;
|
||||
isc_lexspecials_t specials;
|
||||
@@ -515,20 +513,35 @@ loadctx_create(dns_masterformat_t format, isc_mem_t *mctx, unsigned int options,
|
||||
REQUIRE(mctx != NULL);
|
||||
REQUIRE(dns_name_isabsolute(top));
|
||||
REQUIRE(dns_name_isabsolute(origin));
|
||||
REQUIRE((task == NULL && done == NULL) ||
|
||||
(task != NULL && done != NULL));
|
||||
REQUIRE((loop == NULL && done == NULL) ||
|
||||
(loop != NULL && done != NULL));
|
||||
|
||||
lctx = isc_mem_get(mctx, sizeof(*lctx));
|
||||
*lctx = (dns_loadctx_t){
|
||||
.format = format,
|
||||
.ttl_known = ((options & DNS_MASTER_NOTTL) != 0),
|
||||
.default_ttl_known = ((options & DNS_MASTER_NOTTL) != 0),
|
||||
.warn_1035 = true,
|
||||
.warn_tcr = true,
|
||||
.warn_sigexpired = true,
|
||||
.options = options,
|
||||
.zclass = zclass,
|
||||
.resign = resign,
|
||||
.include_cb = include_cb,
|
||||
.include_arg = include_arg,
|
||||
.first = true,
|
||||
.done = done,
|
||||
.callbacks = callbacks,
|
||||
.done_arg = done_arg,
|
||||
.loop_cnt = (done != NULL) ? 100 : 0,
|
||||
|
||||
};
|
||||
|
||||
lctx->inc = NULL;
|
||||
result = incctx_create(mctx, origin, &lctx->inc);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto cleanup_ctx;
|
||||
}
|
||||
|
||||
lctx->maxttl = 0;
|
||||
|
||||
lctx->format = format;
|
||||
switch (format) {
|
||||
case dns_masterformat_text:
|
||||
lctx->openfile = openfile_text;
|
||||
@@ -562,43 +575,20 @@ loadctx_create(dns_masterformat_t format, isc_mem_t *mctx, unsigned int options,
|
||||
isc_lex_setcomments(lctx->lex, ISC_LEXCOMMENT_DNSMASTERFILE);
|
||||
}
|
||||
|
||||
lctx->ttl_known = ((options & DNS_MASTER_NOTTL) != 0);
|
||||
lctx->ttl = 0;
|
||||
lctx->default_ttl_known = lctx->ttl_known;
|
||||
lctx->default_ttl = 0;
|
||||
lctx->warn_1035 = true; /* XXX Argument? */
|
||||
lctx->warn_tcr = true; /* XXX Argument? */
|
||||
lctx->warn_sigexpired = true; /* XXX Argument? */
|
||||
lctx->options = options;
|
||||
lctx->seen_include = false;
|
||||
lctx->zclass = zclass;
|
||||
lctx->resign = resign;
|
||||
lctx->result = ISC_R_SUCCESS;
|
||||
lctx->include_cb = include_cb;
|
||||
lctx->include_arg = include_arg;
|
||||
isc_stdtime_get(&lctx->now);
|
||||
|
||||
lctx->top = dns_fixedname_initname(&lctx->fixed_top);
|
||||
dns_name_toregion(top, &r);
|
||||
dns_name_fromregion(lctx->top, &r);
|
||||
|
||||
lctx->f = NULL;
|
||||
lctx->first = true;
|
||||
dns_master_initrawheader(&lctx->header);
|
||||
|
||||
lctx->loop_cnt = (done != NULL) ? 100 : 0;
|
||||
lctx->callbacks = callbacks;
|
||||
lctx->task = NULL;
|
||||
if (task != NULL) {
|
||||
isc_task_attach(task, &lctx->task);
|
||||
if (loop != NULL) {
|
||||
isc_loop_attach(loop, &lctx->loop);
|
||||
}
|
||||
lctx->done = done;
|
||||
lctx->done_arg = done_arg;
|
||||
atomic_init(&lctx->canceled, false);
|
||||
lctx->mctx = NULL;
|
||||
isc_mem_attach(mctx, &lctx->mctx);
|
||||
|
||||
isc_refcount_init(&lctx->references, 1); /* Implicit attach. */
|
||||
isc_mem_attach(mctx, &lctx->mctx);
|
||||
|
||||
lctx->magic = DNS_LCTX_MAGIC;
|
||||
*lctxp = lctx;
|
||||
@@ -2128,7 +2118,7 @@ load_text(dns_loadctx_t *lctx) {
|
||||
}
|
||||
|
||||
if (!done) {
|
||||
INSIST(lctx->done != NULL && lctx->task != NULL);
|
||||
INSIST(lctx->done != NULL && lctx->loop != NULL);
|
||||
result = DNS_R_CONTINUE;
|
||||
} else if (result == ISC_R_SUCCESS && lctx->result != ISC_R_SUCCESS) {
|
||||
result = lctx->result;
|
||||
@@ -2623,7 +2613,7 @@ load_raw(dns_loadctx_t *lctx) {
|
||||
}
|
||||
|
||||
if (!done) {
|
||||
INSIST(lctx->done != NULL && lctx->task != NULL);
|
||||
INSIST(lctx->done != NULL && lctx->loop != NULL);
|
||||
result = DNS_R_CONTINUE;
|
||||
} else if (result == ISC_R_SUCCESS && lctx->result != ISC_R_SUCCESS) {
|
||||
result = lctx->result;
|
||||
@@ -2685,7 +2675,7 @@ isc_result_t
|
||||
dns_master_loadfileinc(const char *master_file, dns_name_t *top,
|
||||
dns_name_t *origin, dns_rdataclass_t zclass,
|
||||
unsigned int options, uint32_t resign,
|
||||
dns_rdatacallbacks_t *callbacks, isc_task_t *task,
|
||||
dns_rdatacallbacks_t *callbacks, isc_loop_t *loop,
|
||||
dns_loaddonefunc_t done, void *done_arg,
|
||||
dns_loadctx_t **lctxp, dns_masterincludecb_t include_cb,
|
||||
void *include_arg, isc_mem_t *mctx,
|
||||
@@ -2693,11 +2683,11 @@ dns_master_loadfileinc(const char *master_file, dns_name_t *top,
|
||||
dns_loadctx_t *lctx = NULL;
|
||||
isc_result_t result;
|
||||
|
||||
REQUIRE(task != NULL);
|
||||
REQUIRE(loop != NULL);
|
||||
REQUIRE(done != NULL);
|
||||
|
||||
result = loadctx_create(format, mctx, options, resign, top, zclass,
|
||||
origin, callbacks, task, done, done_arg,
|
||||
origin, callbacks, loop, done, done_arg,
|
||||
include_cb, include_arg, NULL, &lctx);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
return (result);
|
||||
@@ -2707,18 +2697,13 @@ dns_master_loadfileinc(const char *master_file, dns_name_t *top,
|
||||
|
||||
result = (lctx->openfile)(lctx, master_file);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto cleanup;
|
||||
dns_loadctx_detach(&lctx);
|
||||
return (result);
|
||||
}
|
||||
|
||||
result = task_send(lctx);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
dns_loadctx_attach(lctx, lctxp);
|
||||
return (DNS_R_CONTINUE);
|
||||
}
|
||||
|
||||
cleanup:
|
||||
dns_loadctx_detach(&lctx);
|
||||
return (result);
|
||||
isc_async_run(loop, load_quantum, lctx);
|
||||
dns_loadctx_attach(lctx, lctxp);
|
||||
return (DNS_R_CONTINUE);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
@@ -2739,7 +2724,8 @@ dns_master_loadstream(FILE *stream, dns_name_t *top, dns_name_t *origin,
|
||||
|
||||
result = isc_lex_openstream(lctx->lex, stream);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto cleanup;
|
||||
dns_loadctx_detach(&lctx);
|
||||
return (result);
|
||||
}
|
||||
|
||||
result = (lctx->load)(lctx);
|
||||
@@ -2752,44 +2738,6 @@ cleanup:
|
||||
return (result);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
dns_master_loadstreaminc(FILE *stream, dns_name_t *top, dns_name_t *origin,
|
||||
dns_rdataclass_t zclass, unsigned int options,
|
||||
dns_rdatacallbacks_t *callbacks, isc_task_t *task,
|
||||
dns_loaddonefunc_t done, void *done_arg,
|
||||
dns_loadctx_t **lctxp, isc_mem_t *mctx) {
|
||||
isc_result_t result;
|
||||
dns_loadctx_t *lctx = NULL;
|
||||
|
||||
REQUIRE(stream != NULL);
|
||||
REQUIRE(task != NULL);
|
||||
REQUIRE(done != NULL);
|
||||
|
||||
result = loadctx_create(dns_masterformat_text, mctx, options, 0, top,
|
||||
zclass, origin, callbacks, task, done, done_arg,
|
||||
NULL, NULL, NULL, &lctx);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
result = isc_lex_openstream(lctx->lex, stream);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
result = task_send(lctx);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
dns_loadctx_attach(lctx, lctxp);
|
||||
return (DNS_R_CONTINUE);
|
||||
}
|
||||
|
||||
cleanup:
|
||||
if (lctx != NULL) {
|
||||
dns_loadctx_detach(&lctx);
|
||||
}
|
||||
return (result);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
dns_master_loadbuffer(isc_buffer_t *buffer, dns_name_t *top, dns_name_t *origin,
|
||||
dns_rdataclass_t zclass, unsigned int options,
|
||||
@@ -2819,96 +2767,6 @@ cleanup:
|
||||
return (result);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
dns_master_loadbufferinc(isc_buffer_t *buffer, dns_name_t *top,
|
||||
dns_name_t *origin, dns_rdataclass_t zclass,
|
||||
unsigned int options, dns_rdatacallbacks_t *callbacks,
|
||||
isc_task_t *task, dns_loaddonefunc_t done,
|
||||
void *done_arg, dns_loadctx_t **lctxp,
|
||||
isc_mem_t *mctx) {
|
||||
isc_result_t result;
|
||||
dns_loadctx_t *lctx = NULL;
|
||||
|
||||
REQUIRE(buffer != NULL);
|
||||
REQUIRE(task != NULL);
|
||||
REQUIRE(done != NULL);
|
||||
|
||||
result = loadctx_create(dns_masterformat_text, mctx, options, 0, top,
|
||||
zclass, origin, callbacks, task, done, done_arg,
|
||||
NULL, NULL, NULL, &lctx);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
return (result);
|
||||
}
|
||||
|
||||
result = isc_lex_openbuffer(lctx->lex, buffer);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
result = task_send(lctx);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
dns_loadctx_attach(lctx, lctxp);
|
||||
return (DNS_R_CONTINUE);
|
||||
}
|
||||
|
||||
cleanup:
|
||||
dns_loadctx_detach(&lctx);
|
||||
return (result);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
dns_master_loadlexer(isc_lex_t *lex, dns_name_t *top, dns_name_t *origin,
|
||||
dns_rdataclass_t zclass, unsigned int options,
|
||||
dns_rdatacallbacks_t *callbacks, isc_mem_t *mctx) {
|
||||
isc_result_t result;
|
||||
dns_loadctx_t *lctx = NULL;
|
||||
|
||||
REQUIRE(lex != NULL);
|
||||
|
||||
result = loadctx_create(dns_masterformat_text, mctx, options, 0, top,
|
||||
zclass, origin, callbacks, NULL, NULL, NULL,
|
||||
NULL, NULL, lex, &lctx);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
return (result);
|
||||
}
|
||||
|
||||
result = (lctx->load)(lctx);
|
||||
INSIST(result != DNS_R_CONTINUE);
|
||||
|
||||
dns_loadctx_detach(&lctx);
|
||||
return (result);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
dns_master_loadlexerinc(isc_lex_t *lex, dns_name_t *top, dns_name_t *origin,
|
||||
dns_rdataclass_t zclass, unsigned int options,
|
||||
dns_rdatacallbacks_t *callbacks, isc_task_t *task,
|
||||
dns_loaddonefunc_t done, void *done_arg,
|
||||
dns_loadctx_t **lctxp, isc_mem_t *mctx) {
|
||||
isc_result_t result;
|
||||
dns_loadctx_t *lctx = NULL;
|
||||
|
||||
REQUIRE(lex != NULL);
|
||||
REQUIRE(task != NULL);
|
||||
REQUIRE(done != NULL);
|
||||
|
||||
result = loadctx_create(dns_masterformat_text, mctx, options, 0, top,
|
||||
zclass, origin, callbacks, task, done, done_arg,
|
||||
NULL, NULL, lex, &lctx);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
return (result);
|
||||
}
|
||||
|
||||
result = task_send(lctx);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
dns_loadctx_attach(lctx, lctxp);
|
||||
return (DNS_R_CONTINUE);
|
||||
}
|
||||
|
||||
dns_loadctx_detach(&lctx);
|
||||
return (result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Grow the slab of dns_rdatalist_t structures.
|
||||
* Re-link glue and current list.
|
||||
@@ -3154,12 +3012,10 @@ is_glue(rdatalist_head_t *head, dns_name_t *owner) {
|
||||
}
|
||||
|
||||
static void
|
||||
load_quantum(isc_task_t *task, isc_event_t *event) {
|
||||
load_quantum(void *arg) {
|
||||
isc_result_t result;
|
||||
dns_loadctx_t *lctx;
|
||||
dns_loadctx_t *lctx = (dns_loadctx_t *)arg;
|
||||
|
||||
REQUIRE(event != NULL);
|
||||
lctx = event->ev_arg;
|
||||
REQUIRE(DNS_LCTX_VALID(lctx));
|
||||
|
||||
if (atomic_load_acquire(&lctx->canceled)) {
|
||||
@@ -3168,25 +3024,13 @@ load_quantum(isc_task_t *task, isc_event_t *event) {
|
||||
result = (lctx->load)(lctx);
|
||||
}
|
||||
if (result == DNS_R_CONTINUE) {
|
||||
event->ev_arg = lctx;
|
||||
isc_task_send(task, &event);
|
||||
isc_async_run(lctx->loop, load_quantum, lctx);
|
||||
} else {
|
||||
(lctx->done)(lctx->done_arg, result);
|
||||
isc_event_free(&event);
|
||||
dns_loadctx_detach(&lctx);
|
||||
}
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
task_send(dns_loadctx_t *lctx) {
|
||||
isc_event_t *event;
|
||||
|
||||
event = isc_event_allocate(lctx->mctx, NULL, DNS_EVENT_MASTERQUANTUM,
|
||||
load_quantum, lctx, sizeof(*event));
|
||||
isc_task_send(lctx->task, &event);
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
void
|
||||
dns_loadctx_cancel(dns_loadctx_t *lctx) {
|
||||
REQUIRE(DNS_LCTX_VALID(lctx));
|
||||
|
@@ -2415,17 +2415,13 @@ dns_zone_load(dns_zone_t *zone, bool newonly) {
|
||||
}
|
||||
|
||||
static void
|
||||
zone_asyncload(isc_task_t *task, isc_event_t *event) {
|
||||
dns_asyncload_t *asl = event->ev_arg;
|
||||
zone_asyncload(void *arg) {
|
||||
dns_asyncload_t *asl = arg;
|
||||
dns_zone_t *zone = asl->zone;
|
||||
isc_result_t result;
|
||||
|
||||
UNUSED(task);
|
||||
|
||||
REQUIRE(DNS_ZONE_VALID(zone));
|
||||
|
||||
isc_event_free(&event);
|
||||
|
||||
LOCK_ZONE(zone);
|
||||
result = zone_load(zone, asl->flags, true);
|
||||
if (result != DNS_R_CONTINUE) {
|
||||
@@ -2435,7 +2431,7 @@ zone_asyncload(isc_task_t *task, isc_event_t *event) {
|
||||
|
||||
/* Inform the zone table we've finished loading */
|
||||
if (asl->loaded != NULL) {
|
||||
(asl->loaded)(asl->loaded_arg, zone, task);
|
||||
(asl->loaded)(asl->loaded_arg, zone, zone->task);
|
||||
}
|
||||
|
||||
isc_mem_put(zone->mctx, asl, sizeof(*asl));
|
||||
@@ -2445,7 +2441,6 @@ zone_asyncload(isc_task_t *task, isc_event_t *event) {
|
||||
isc_result_t
|
||||
dns_zone_asyncload(dns_zone_t *zone, bool newonly, dns_zt_zoneloaded_t done,
|
||||
void *arg) {
|
||||
isc_event_t *e;
|
||||
dns_asyncload_t *asl = NULL;
|
||||
|
||||
REQUIRE(DNS_ZONE_VALID(zone));
|
||||
@@ -2468,12 +2463,9 @@ dns_zone_asyncload(dns_zone_t *zone, bool newonly, dns_zt_zoneloaded_t done,
|
||||
asl->loaded = done;
|
||||
asl->loaded_arg = arg;
|
||||
|
||||
e = isc_event_allocate(zone->zmgr->mctx, zone->zmgr, DNS_EVENT_ZONELOAD,
|
||||
zone_asyncload, asl, sizeof(isc_event_t));
|
||||
|
||||
zone_iattach(zone, &asl->zone);
|
||||
DNS_ZONE_SETFLAG(zone, DNS_ZONEFLG_LOADPENDING);
|
||||
isc_task_send(zone->loadtask, &e);
|
||||
isc_async_run(zone->loop, zone_asyncload, asl);
|
||||
UNLOCK_ZONE(zone);
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
@@ -2612,6 +2604,8 @@ zone_gotreadhandle(isc_task_t *task, isc_event_t *event) {
|
||||
|
||||
REQUIRE(DNS_LOAD_VALID(load));
|
||||
|
||||
UNUSED(task);
|
||||
|
||||
if ((event->ev_attributes & ISC_EVENTATTR_CANCELED) != 0) {
|
||||
result = ISC_R_CANCELED;
|
||||
}
|
||||
@@ -2625,9 +2619,9 @@ zone_gotreadhandle(isc_task_t *task, isc_event_t *event) {
|
||||
result = dns_master_loadfileinc(
|
||||
load->zone->masterfile, dns_db_origin(load->db),
|
||||
dns_db_origin(load->db), load->zone->rdclass, options, 0,
|
||||
&load->callbacks, task, zone_loaddone, load, &load->zone->lctx,
|
||||
zone_registerinclude, load->zone, load->zone->mctx,
|
||||
load->zone->masterformat, load->zone->maxttl);
|
||||
&load->callbacks, load->zone->loop, zone_loaddone, load,
|
||||
&load->zone->lctx, zone_registerinclude, load->zone,
|
||||
load->zone->mctx, load->zone->masterformat, load->zone->maxttl);
|
||||
if (result != ISC_R_SUCCESS && result != DNS_R_CONTINUE &&
|
||||
result != DNS_R_SEENINCLUDE)
|
||||
{
|
||||
@@ -2762,7 +2756,7 @@ zone_startload(dns_db_t *db, dns_zone_t *zone, isc_time_t loadtime) {
|
||||
options |= DNS_MASTER_MANYERRORS;
|
||||
}
|
||||
|
||||
if (zone->zmgr != NULL && zone->db != NULL && zone->loadtask != NULL) {
|
||||
if (zone->zmgr != NULL && zone->db != NULL) {
|
||||
load = isc_mem_get(zone->mctx, sizeof(*load));
|
||||
|
||||
load->mctx = NULL;
|
||||
|
Reference in New Issue
Block a user