dns_dumpctx_t *mdctx;
dns_db_t *db;
dns_db_t *cache;
- isc_task_t *task;
+ isc_loop_t *loop;
dns_dbversion_t *version;
};
if (dctx->cache != NULL) {
dns_db_detach(&dctx->cache);
}
- if (dctx->task != NULL) {
- isc_task_detach(&dctx->task);
- }
if (dctx->fp != NULL) {
(void)isc_stdio_close(dctx->fp);
}
dns_cache_getname(dctx->view->view->cache));
result = dns_master_dumptostreamasync(
dctx->mctx, dctx->cache, NULL, style, dctx->fp,
- dctx->task, dumpdone, dctx, &dctx->mdctx);
+ named_g_mainloop, dumpdone, dctx, &dctx->mdctx);
if (result == DNS_R_CONTINUE) {
return;
}
dns_db_currentversion(dctx->db, &dctx->version);
result = dns_master_dumptostreamasync(
dctx->mctx, dctx->db, dctx->version, style,
- dctx->fp, dctx->task, dumpdone, dctx,
+ dctx->fp, named_g_mainloop, dumpdone, dctx,
&dctx->mdctx);
if (result == DNS_R_CONTINUE) {
return;
}
dctx = isc_mem_get(server->mctx, sizeof(*dctx));
-
- dctx->mctx = server->mctx;
- dctx->dumpcache = true;
- dctx->dumpadb = true;
- dctx->dumpbad = true;
- dctx->dumpexpired = false;
- dctx->dumpfail = true;
- dctx->dumpzones = false;
- dctx->fp = NULL;
- ISC_LIST_INIT(dctx->viewlist);
- dctx->view = NULL;
- dctx->zone = NULL;
- dctx->cache = NULL;
- dctx->mdctx = NULL;
- dctx->db = NULL;
- dctx->cache = NULL;
- dctx->task = NULL;
- dctx->version = NULL;
- isc_task_attach(server->task, &dctx->task);
+ *dctx = (struct dumpcontext){
+ .mctx = server->mctx,
+ .dumpcache = true,
+ .dumpadb = true,
+ .dumpbad = true,
+ .dumpfail = true,
+ .viewlist = ISC_LIST_INITIALIZER,
+ };
CHECKMF(isc_stdio_open(server->dumpfile, "w", &dctx->fp),
"could not open dump file", server->dumpfile);
dns_master_dumptostreamasync(isc_mem_t *mctx, dns_db_t *db,
dns_dbversion_t *version,
const dns_master_style_t *style, FILE *f,
- isc_task_t *task, dns_dumpdonefunc_t done,
+ isc_loop_t *loop, dns_dumpdonefunc_t done,
void *done_arg, dns_dumpctx_t **dctxp);
isc_result_t
* Temporary dynamic memory may be allocated from 'mctx'.
*
* Require:
- *\li 'task' to be valid.
*\li 'done' to be non NULL.
*\li 'dctxp' to be non NULL && '*dctxp' to be NULL.
*
isc_result_t
dns_master_dumpasync(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
const dns_master_style_t *style, const char *filename,
- isc_task_t *task, dns_dumpdonefunc_t done, void *done_arg,
+ isc_loop_t *loop, dns_dumpdonefunc_t done, void *done_arg,
dns_dumpctx_t **dctxp, dns_masterformat_t format,
dns_masterrawheader_t *header);
#include <stdbool.h>
#include <stdlib.h>
+#include <isc/async.h>
#include <isc/atomic.h>
#include <isc/buffer.h>
#include <isc/event.h>
#include <isc/file.h>
+#include <isc/loop.h>
#include <isc/magic.h>
#include <isc/mem.h>
#include <isc/print.h>
#include <isc/result.h>
#include <isc/stdio.h>
#include <isc/string.h>
-#include <isc/task.h>
#include <isc/time.h>
#include <isc/types.h>
#include <isc/util.h>
dns_dbversion_t *version;
dns_dbiterator_t *dbiter;
dns_totext_ctx_t tctx;
- isc_task_t *task;
+ isc_loop_t *loop;
dns_dumpdonefunc_t done;
void *done_arg;
/* dns_master_dumpasync() */
dns_db_closeversion(dctx->db, &dctx->version, false);
}
dns_db_detach(&dctx->db);
- if (dctx->task != NULL) {
- isc_task_detach(&dctx->task);
+ if (dctx->loop != NULL) {
+ isc_loop_detach(&dctx->loop);
}
if (dctx->file != NULL) {
isc_mem_free(dctx->mctx, dctx->file);
}
/*
- * This will run in a network/task manager thread when the dump is complete.
+ * This will run in a loop manager thread when the dump is complete.
*/
static void
master_dump_done_cb(void *data) {
}
/*
- * This must be run from a network/task manager thread.
+ * This must be run from a loop manager thread.
*/
static void
-setup_dump(isc_task_t *task, isc_event_t *event) {
- dns_dumpctx_t *dctx = NULL;
- isc_loopmgr_t *loopmgr = isc_task_getloopmgr(task);
- isc_loop_t *loop = isc_loop_current(loopmgr);
-
- REQUIRE(event != NULL);
-
- dctx = event->ev_arg;
+setup_dump(void *arg) {
+ dns_dumpctx_t *dctx = (dns_dumpctx_t *)arg;
REQUIRE(DNS_DCTX_VALID(dctx));
- isc_work_enqueue(loop, master_dump_cb, master_dump_done_cb, dctx);
-
- isc_event_free(&event);
-}
-
-static isc_result_t
-task_send(dns_dumpctx_t *dctx) {
- isc_event_t *event;
-
- event = isc_event_allocate(dctx->mctx, NULL, DNS_EVENT_DUMPQUANTUM,
- setup_dump, dctx, sizeof(*event));
- isc_task_send(dctx->task, &event);
- return (ISC_R_SUCCESS);
+ isc_work_enqueue(dctx->loop, master_dump_cb, master_dump_done_cb, dctx);
}
static isc_result_t
unsigned int options;
dctx = isc_mem_get(mctx, sizeof(*dctx));
+ *dctx = (dns_dumpctx_t){
+ .f = f,
+ .format = format,
+ };
- dctx->mctx = NULL;
- dctx->f = f;
- dctx->dbiter = NULL;
- dctx->db = NULL;
- dctx->version = NULL;
- dctx->done = NULL;
- dctx->done_arg = NULL;
- dctx->task = NULL;
- atomic_init(&dctx->canceled, false);
- dctx->file = NULL;
- dctx->tmpfile = NULL;
- dctx->format = format;
if (header == NULL) {
dns_master_initrawheader(&dctx->header);
} else {
dns_master_dumptostreamasync(isc_mem_t *mctx, dns_db_t *db,
dns_dbversion_t *version,
const dns_master_style_t *style, FILE *f,
- isc_task_t *task, dns_dumpdonefunc_t done,
+ isc_loop_t *loop, dns_dumpdonefunc_t done,
void *done_arg, dns_dumpctx_t **dctxp) {
dns_dumpctx_t *dctx = NULL;
isc_result_t result;
- REQUIRE(task != NULL);
+ REQUIRE(loop != NULL);
REQUIRE(f != NULL);
REQUIRE(done != NULL);
if (result != ISC_R_SUCCESS) {
return (result);
}
- isc_task_attach(task, &dctx->task);
+ isc_loop_attach(loop, &dctx->loop);
dctx->done = done;
dctx->done_arg = done_arg;
- result = task_send(dctx);
- if (result == ISC_R_SUCCESS) {
- dns_dumpctx_attach(dctx, dctxp);
- return (DNS_R_CONTINUE);
- }
-
- dns_dumpctx_detach(&dctx);
- return (result);
+ isc_async_run(dctx->loop, setup_dump, dctx);
+ dns_dumpctx_attach(dctx, dctxp);
+ return (DNS_R_CONTINUE);
}
isc_result_t
isc_result_t
dns_master_dumpasync(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
const dns_master_style_t *style, const char *filename,
- isc_task_t *task, dns_dumpdonefunc_t done, void *done_arg,
+ isc_loop_t *loop, dns_dumpdonefunc_t done, void *done_arg,
dns_dumpctx_t **dctxp, dns_masterformat_t format,
dns_masterrawheader_t *header) {
FILE *f = NULL;
goto cleanup;
}
- isc_task_attach(task, &dctx->task);
+ isc_loop_attach(loop, &dctx->loop);
dctx->done = done;
dctx->done_arg = done_arg;
dctx->file = file;
dctx->tmpfile = tempname;
tempname = NULL;
- result = task_send(dctx);
- if (result == ISC_R_SUCCESS) {
- dns_dumpctx_attach(dctx, dctxp);
- return (DNS_R_CONTINUE);
- }
+ isc_async_run(dctx->loop, setup_dump, dctx);
+ dns_dumpctx_attach(dctx, dctxp);
+ return (DNS_R_CONTINUE);
cleanup:
if (dctx != NULL) {