mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-29 13:38:26 +00:00
Refactor dns_master_dump*async() to use offloaded work
The dns_master_dump*async() functions were using isc_async_run() to schedule work on the active loop; use isc_work_enqueue() instead.
This commit is contained in:
parent
b54c721894
commit
04670889bc
@ -11611,7 +11611,7 @@ resume:
|
|||||||
result = dns_master_dumptostreamasync(
|
result = dns_master_dumptostreamasync(
|
||||||
dctx->mctx, dctx->cache, NULL, style, dctx->fp,
|
dctx->mctx, dctx->cache, NULL, style, dctx->fp,
|
||||||
named_g_mainloop, dumpdone, dctx, &dctx->mdctx);
|
named_g_mainloop, dumpdone, dctx, &dctx->mdctx);
|
||||||
if (result == DNS_R_CONTINUE) {
|
if (result == ISC_R_SUCCESS) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (result == ISC_R_NOTIMPLEMENTED) {
|
if (result == ISC_R_NOTIMPLEMENTED) {
|
||||||
@ -11670,9 +11670,9 @@ resume:
|
|||||||
dns_db_currentversion(dctx->db, &dctx->version);
|
dns_db_currentversion(dctx->db, &dctx->version);
|
||||||
result = dns_master_dumptostreamasync(
|
result = dns_master_dumptostreamasync(
|
||||||
dctx->mctx, dctx->db, dctx->version, style,
|
dctx->mctx, dctx->db, dctx->version, style,
|
||||||
dctx->fp, named_g_mainloop, dumpdone, dctx,
|
dctx->fp, dns_zone_getloop(dctx->zone->zone),
|
||||||
&dctx->mdctx);
|
dumpdone, dctx, &dctx->mdctx);
|
||||||
if (result == DNS_R_CONTINUE) {
|
if (result == ISC_R_SUCCESS) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (result == ISC_R_NOTIMPLEMENTED) {
|
if (result == ISC_R_NOTIMPLEMENTED) {
|
||||||
|
@ -2753,6 +2753,16 @@ dns_zone_gettid(dns_zone_t *zone);
|
|||||||
* \return thread id associated with the zone
|
* \return thread id associated with the zone
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
isc_loop_t *
|
||||||
|
dns_zone_getloop(dns_zone_t *zone);
|
||||||
|
/**<
|
||||||
|
* \brief Return loop associated with the zone.
|
||||||
|
*
|
||||||
|
* \param valid dns_zone_t object
|
||||||
|
*
|
||||||
|
* \return loop associated with the zone
|
||||||
|
*/
|
||||||
|
|
||||||
bool
|
bool
|
||||||
dns_zone_check_dnskey_nsec3(dns_zone_t *zone, dns_db_t *db,
|
dns_zone_check_dnskey_nsec3(dns_zone_t *zone, dns_db_t *db,
|
||||||
dns_dbversion_t *ver, dns_diff_t *diff,
|
dns_dbversion_t *ver, dns_diff_t *diff,
|
||||||
|
@ -262,7 +262,6 @@ struct dns_dumpctx {
|
|||||||
dns_dbversion_t *version;
|
dns_dbversion_t *version;
|
||||||
dns_dbiterator_t *dbiter;
|
dns_dbiterator_t *dbiter;
|
||||||
dns_totext_ctx_t tctx;
|
dns_totext_ctx_t tctx;
|
||||||
isc_loop_t *loop;
|
|
||||||
dns_dumpdonefunc_t done;
|
dns_dumpdonefunc_t done;
|
||||||
void *done_arg;
|
void *done_arg;
|
||||||
/* dns_master_dumpasync() */
|
/* dns_master_dumpasync() */
|
||||||
@ -1072,7 +1071,6 @@ again:
|
|||||||
sorted[i] = &rdatasets[i];
|
sorted[i] = &rdatasets[i];
|
||||||
}
|
}
|
||||||
n = i;
|
n = i;
|
||||||
INSIST(n <= MAXSORT);
|
|
||||||
|
|
||||||
qsort(sorted, n, sizeof(sorted[0]), dump_order_compare);
|
qsort(sorted, n, sizeof(sorted[0]), dump_order_compare);
|
||||||
|
|
||||||
@ -1335,9 +1333,6 @@ dumpctx_destroy(dns_dumpctx_t *dctx) {
|
|||||||
dns_db_closeversion(dctx->db, &dctx->version, false);
|
dns_db_closeversion(dctx->db, &dctx->version, false);
|
||||||
}
|
}
|
||||||
dns_db_detach(&dctx->db);
|
dns_db_detach(&dctx->db);
|
||||||
if (dctx->loop != NULL) {
|
|
||||||
isc_loop_detach(&dctx->loop);
|
|
||||||
}
|
|
||||||
if (dctx->file != NULL) {
|
if (dctx->file != NULL) {
|
||||||
isc_mem_free(dctx->mctx, dctx->file);
|
isc_mem_free(dctx->mctx, dctx->file);
|
||||||
}
|
}
|
||||||
@ -1507,18 +1502,6 @@ master_dump_done_cb(void *data) {
|
|||||||
dns_dumpctx_detach(&dctx);
|
dns_dumpctx_detach(&dctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* This must be run from a loop manager thread.
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
setup_dump(void *arg) {
|
|
||||||
dns_dumpctx_t *dctx = (dns_dumpctx_t *)arg;
|
|
||||||
|
|
||||||
REQUIRE(DNS_DCTX_VALID(dctx));
|
|
||||||
|
|
||||||
isc_work_enqueue(dctx->loop, master_dump_cb, master_dump_done_cb, dctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
static isc_result_t
|
static isc_result_t
|
||||||
dumpctx_create(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
|
dumpctx_create(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
|
||||||
const dns_master_style_t *style, FILE *f, dns_dumpctx_t **dctxp,
|
const dns_master_style_t *style, FILE *f, dns_dumpctx_t **dctxp,
|
||||||
@ -1761,13 +1744,13 @@ dns_master_dumptostreamasync(isc_mem_t *mctx, dns_db_t *db,
|
|||||||
if (result != ISC_R_SUCCESS) {
|
if (result != ISC_R_SUCCESS) {
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
isc_loop_attach(loop, &dctx->loop);
|
|
||||||
dctx->done = done;
|
dctx->done = done;
|
||||||
dctx->done_arg = done_arg;
|
dctx->done_arg = done_arg;
|
||||||
|
|
||||||
isc_async_run(dctx->loop, setup_dump, dctx);
|
|
||||||
dns_dumpctx_attach(dctx, dctxp);
|
dns_dumpctx_attach(dctx, dctxp);
|
||||||
return (DNS_R_CONTINUE);
|
isc_work_enqueue(loop, master_dump_cb, master_dump_done_cb, dctx);
|
||||||
|
|
||||||
|
return (ISC_R_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
isc_result_t
|
isc_result_t
|
||||||
@ -1850,39 +1833,33 @@ dns_master_dumpasync(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
|
|||||||
|
|
||||||
result = opentmp(mctx, format, filename, &tempname, &f);
|
result = opentmp(mctx, format, filename, &tempname, &f);
|
||||||
if (result != ISC_R_SUCCESS) {
|
if (result != ISC_R_SUCCESS) {
|
||||||
goto cleanup;
|
goto cleanup_file;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = dumpctx_create(mctx, db, version, style, f, &dctx, format,
|
result = dumpctx_create(mctx, db, version, style, f, &dctx, format,
|
||||||
header);
|
header);
|
||||||
if (result != ISC_R_SUCCESS) {
|
if (result != ISC_R_SUCCESS) {
|
||||||
(void)isc_stdio_close(f);
|
goto cleanup_tempname;
|
||||||
(void)isc_file_remove(tempname);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
isc_loop_attach(loop, &dctx->loop);
|
|
||||||
dctx->done = done;
|
dctx->done = done;
|
||||||
dctx->done_arg = done_arg;
|
dctx->done_arg = done_arg;
|
||||||
dctx->file = file;
|
dctx->file = file;
|
||||||
file = NULL;
|
|
||||||
dctx->tmpfile = tempname;
|
dctx->tmpfile = tempname;
|
||||||
tempname = NULL;
|
|
||||||
|
|
||||||
isc_async_run(dctx->loop, setup_dump, dctx);
|
|
||||||
dns_dumpctx_attach(dctx, dctxp);
|
dns_dumpctx_attach(dctx, dctxp);
|
||||||
return (DNS_R_CONTINUE);
|
isc_work_enqueue(loop, master_dump_cb, master_dump_done_cb, dctx);
|
||||||
|
|
||||||
|
return (ISC_R_SUCCESS);
|
||||||
|
|
||||||
|
cleanup_tempname:
|
||||||
|
(void)isc_stdio_close(f);
|
||||||
|
(void)isc_file_remove(tempname);
|
||||||
|
isc_mem_free(mctx, tempname);
|
||||||
|
|
||||||
|
cleanup_file:
|
||||||
|
isc_mem_free(mctx, file);
|
||||||
|
|
||||||
cleanup:
|
|
||||||
if (dctx != NULL) {
|
|
||||||
dns_dumpctx_detach(&dctx);
|
|
||||||
}
|
|
||||||
if (file != NULL) {
|
|
||||||
isc_mem_free(mctx, file);
|
|
||||||
}
|
|
||||||
if (tempname != NULL) {
|
|
||||||
isc_mem_free(mctx, tempname);
|
|
||||||
}
|
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2701,7 +2701,7 @@ zone_gotwritehandle(isc_task_t *task, isc_event_t *event) {
|
|||||||
dns_db_detach(&db);
|
dns_db_detach(&db);
|
||||||
}
|
}
|
||||||
UNLOCK_ZONE(zone);
|
UNLOCK_ZONE(zone);
|
||||||
if (result != DNS_R_CONTINUE) {
|
if (result != ISC_R_SUCCESS) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -12174,8 +12174,6 @@ redo:
|
|||||||
&zone->writeio);
|
&zone->writeio);
|
||||||
if (result != ISC_R_SUCCESS) {
|
if (result != ISC_R_SUCCESS) {
|
||||||
zone_idetach(&dummy);
|
zone_idetach(&dummy);
|
||||||
} else {
|
|
||||||
result = DNS_R_CONTINUE;
|
|
||||||
}
|
}
|
||||||
UNLOCK_ZONE(zone);
|
UNLOCK_ZONE(zone);
|
||||||
} else {
|
} else {
|
||||||
@ -12205,7 +12203,7 @@ fail:
|
|||||||
}
|
}
|
||||||
masterfile = NULL;
|
masterfile = NULL;
|
||||||
|
|
||||||
if (result == DNS_R_CONTINUE) {
|
if (result == ISC_R_SUCCESS) {
|
||||||
return (ISC_R_SUCCESS); /* XXXMPA */
|
return (ISC_R_SUCCESS); /* XXXMPA */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23674,3 +23672,8 @@ unsigned int
|
|||||||
dns_zone_gettid(dns_zone_t *zone) {
|
dns_zone_gettid(dns_zone_t *zone) {
|
||||||
return (zone->tid);
|
return (zone->tid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isc_loop_t *
|
||||||
|
dns_zone_getloop(dns_zone_t *zone) {
|
||||||
|
return (zone->loop);
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user