isc_sockaddr_t notifyfrom;
isc_task_t *task;
- isc_task_t *loadtask;
isc_sockaddr_t notifysrc4;
isc_sockaddr_t notifysrc6;
isc_nm_t *netmgr;
uint32_t workers;
isc_task_t **zonetasks;
- isc_task_t **loadtasks;
isc_mem_t **mctxpool;
isc_ratelimiter_t *checkdsrl;
isc_ratelimiter_t *notifyrl;
struct dns_io {
unsigned int magic;
dns_zonemgr_t *zmgr;
+ isc_loop_t *loop;
+ isc_job_cb cb;
+ void *arg;
bool high;
- isc_task_t *task;
+ bool canceled;
ISC_LINK(dns_io_t) link;
- isc_event_t *event;
};
/*%
static void
zonemgr_free(dns_zonemgr_t *zmgr);
static isc_result_t
-zonemgr_getio(dns_zonemgr_t *zmgr, bool high, isc_task_t *task,
- isc_taskaction_t action, void *arg, dns_io_t **iop);
+zonemgr_getio(dns_zonemgr_t *zmgr, bool high, isc_loop_t *loop, isc_job_cb cb,
+ void *arg, dns_io_t **iop);
static void
zonemgr_putio(dns_io_t **iop);
static void
if (zone->task != NULL) {
isc_task_detach(&zone->task);
}
- if (zone->loadtask != NULL) {
- isc_task_detach(&zone->loadtask);
- }
/* Unmanaged objects */
while (!ISC_LIST_EMPTY(zone->setnsec3param_queue)) {
}
static void
-zone_gotreadhandle(isc_task_t *task, isc_event_t *event) {
- dns_load_t *load = event->ev_arg;
+zone_gotreadhandle(void *arg) {
+ dns_load_t *load = (dns_load_t *)arg;
isc_result_t result = ISC_R_SUCCESS;
unsigned int options;
REQUIRE(DNS_LOAD_VALID(load));
- UNUSED(task);
-
- if ((event->ev_attributes & ISC_EVENTATTR_CANCELED) != 0) {
- result = ISC_R_CANCELED;
- }
- isc_event_free(&event);
- if (result == ISC_R_CANCELED) {
- goto fail;
- }
-
options = get_primary_options(load->zone);
result = dns_master_loadfileasync(
}
static void
-zone_gotwritehandle(isc_task_t *task, isc_event_t *event) {
- dns_zone_t *zone = event->ev_arg;
+zone_gotwritehandle(void *arg) {
+ dns_zone_t *zone = (dns_zone_t *)arg;
isc_result_t result = ISC_R_SUCCESS;
dns_dbversion_t *version = NULL;
dns_masterrawheader_t rawdata;
dns_db_t *db = NULL;
REQUIRE(DNS_ZONE_VALID(zone));
- INSIST(task == zone->task);
ENTER;
- if ((event->ev_attributes & ISC_EVENTATTR_CANCELED) != 0) {
- result = ISC_R_CANCELED;
- }
- isc_event_free(&event);
- if (result == ISC_R_CANCELED) {
- goto fail;
- }
-
LOCK_ZONE(zone);
INSIST(zone != zone->raw);
ZONEDB_LOCK(&zone->dblock, isc_rwlocktype_read);
if (zone->zmgr != NULL && zone->db != NULL) {
load = isc_mem_get(zone->mctx, sizeof(*load));
-
- load->mctx = NULL;
- load->zone = NULL;
- load->db = NULL;
- load->loadtime = loadtime;
- load->magic = LOAD_MAGIC;
+ *load = (dns_load_t){
+ .loadtime = loadtime,
+ .magic = LOAD_MAGIC,
+ };
isc_mem_attach(zone->mctx, &load->mctx);
zone_iattach(zone, &load->zone);
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
- result = zonemgr_getio(zone->zmgr, true, zone->loadtask,
+ result = zonemgr_getio(zone->zmgr, true, zone->loop,
zone_gotreadhandle, load, &zone->readio);
if (result != ISC_R_SUCCESS) {
/*
dns_zone_t *dummy = NULL;
LOCK_ZONE(zone);
zone_iattach(zone, &dummy);
- result = zonemgr_getio(zone->zmgr, false, zone->task,
+ result = zonemgr_getio(zone->zmgr, false, zone->loop,
zone_gotwritehandle, zone,
&zone->writeio);
if (result != ISC_R_SUCCESS) {
isc_task_setname(zmgr->zonetasks[i], "zonemgr-zonetasks", NULL);
}
- zmgr->loadtasks = isc_mem_getx(
- zmgr->mctx, zmgr->workers * sizeof(zmgr->loadtasks[0]),
- ISC_MEM_ZERO);
- for (size_t i = 0; i < zmgr->workers; i++) {
- result = isc_task_create(zmgr->taskmgr, &zmgr->loadtasks[i], i);
- INSIST(result == ISC_R_SUCCESS);
- if (result != ISC_R_SUCCESS) {
- goto free_loadtasks;
- }
- isc_task_setname(zmgr->loadtasks[i], "zonemgr-loadtasks", NULL);
- }
-
zmgr->mctxpool = isc_mem_getx(zmgr->mctx,
zmgr->workers * sizeof(zmgr->mctxpool[0]),
ISC_MEM_ZERO);
free_iolock:
isc_mutex_destroy(&zmgr->iolock);
#endif /* if 0 */
-free_loadtasks:
- for (size_t i = 0; i < zmgr->workers; i++) {
- if (zmgr->loadtasks[i] != NULL) {
- isc_task_detach(&zmgr->loadtasks[i]);
- }
- }
- isc_mem_put(zmgr->mctx, zmgr->loadtasks,
- zmgr->workers * sizeof(zmgr->loadtasks[0]));
free_zonetasks:
for (size_t i = 0; i < zmgr->workers; i++) {
REQUIRE(zone->zmgr == NULL);
isc_task_attach(zmgr->zonetasks[zone->tid], &zone->task);
- isc_task_attach(zmgr->loadtasks[zone->tid], &zone->loadtask);
/*
* Set the task name. The tag will arbitrarily point to one
* to be managed last).
*/
isc_task_setname(zone->task, "zone", zone);
- isc_task_setname(zone->loadtask, "loadzone", zone);
zone->loop = isc_loop_get(zmgr->loopmgr, zone->tid);
isc_mem_detach(&zmgr->mctxpool[i]);
}
- for (size_t i = 0; i < zmgr->workers; i++) {
- isc_task_detach(&zmgr->loadtasks[i]);
- }
-
for (size_t i = 0; i < zmgr->workers; i++) {
isc_task_detach(&zmgr->zonetasks[i]);
}
isc_mem_put(zmgr->mctx, zmgr->mctxpool,
zmgr->workers * sizeof(zmgr->mctxpool[0]));
- isc_mem_put(zmgr->mctx, zmgr->loadtasks,
- zmgr->workers * sizeof(zmgr->loadtasks[0]));
isc_mem_put(zmgr->mctx, zmgr->zonetasks,
zmgr->workers * sizeof(zmgr->zonetasks[0]));
*/
static isc_result_t
-zonemgr_getio(dns_zonemgr_t *zmgr, bool high, isc_task_t *task,
- isc_taskaction_t action, void *arg, dns_io_t **iop) {
- dns_io_t *io;
+zonemgr_getio(dns_zonemgr_t *zmgr, bool high, isc_loop_t *loop, isc_job_cb cb,
+ void *arg, dns_io_t **iop) {
+ dns_io_t *io = NULL;
bool queue;
REQUIRE(DNS_ZONEMGR_VALID(zmgr));
REQUIRE(iop != NULL && *iop == NULL);
io = isc_mem_get(zmgr->mctx, sizeof(*io));
+ *io = (dns_io_t){
+ .zmgr = zmgr,
+ .high = high,
+ .cb = cb,
+ .arg = arg,
+ .link = ISC_LINK_INITIALIZER,
+ };
- io->event = isc_event_allocate(zmgr->mctx, task, DNS_EVENT_IOREADY,
- action, arg, sizeof(*io->event));
-
- io->zmgr = zmgr;
- io->high = high;
- io->task = NULL;
- isc_task_attach(task, &io->task);
- ISC_LINK_INIT(io, link);
+ isc_loop_attach(loop, &io->loop);
io->magic = IO_MAGIC;
LOCK(&zmgr->iolock);
*iop = io;
if (!queue) {
- isc_task_send(io->task, &io->event);
+ isc_async_run(loop, cb, arg);
}
return (ISC_R_SUCCESS);
}
static void
zonemgr_putio(dns_io_t **iop) {
- dns_io_t *io;
- dns_io_t *next;
- dns_zonemgr_t *zmgr;
+ dns_io_t *io = NULL;
+ dns_io_t *next = NULL;
+ dns_zonemgr_t *zmgr = NULL;
REQUIRE(iop != NULL);
+
io = *iop;
*iop = NULL;
+
REQUIRE(DNS_IO_VALID(io));
INSIST(!ISC_LINK_LINKED(io, link));
- INSIST(io->event == NULL);
- zmgr = io->zmgr;
- isc_task_detach(&io->task);
io->magic = 0;
+ zmgr = io->zmgr;
+ isc_loop_detach(&io->loop);
isc_mem_put(zmgr->mctx, io, sizeof(*io));
LOCK(&zmgr->iolock);
} else {
ISC_LIST_UNLINK(zmgr->low, next, link);
}
- INSIST(next->event != NULL);
}
UNLOCK(&zmgr->iolock);
if (next != NULL) {
- isc_task_send(next->task, &next->event);
+ isc_async_run(next->loop, next->cb, next->arg);
}
}
}
send_event = true;
- INSIST(io->event != NULL);
}
UNLOCK(&io->zmgr->iolock);
if (send_event) {
- io->event->ev_attributes |= ISC_EVENTATTR_CANCELED;
- isc_task_send(io->task, &io->event);
+ io->canceled = true;
+ isc_async_run(io->loop, io->cb, io->arg);
}
}
REQUIRE(DNS_ZONE_VALID(zone));
REQUIRE(zone->zmgr != NULL);
REQUIRE(zone->task != NULL);
- REQUIRE(zone->loadtask != NULL);
REQUIRE(zone->raw == NULL);
REQUIRE(DNS_ZONE_VALID(raw));
REQUIRE(raw->zmgr == NULL);
REQUIRE(raw->task == NULL);
- REQUIRE(raw->loadtask == NULL);
REQUIRE(raw->secure == NULL);
REQUIRE(zone != raw);
zone_iattach(zone, &raw->secure);
isc_task_attach(zone->task, &raw->task);
- isc_task_attach(zone->loadtask, &raw->loadtask);
ISC_LIST_APPEND(zmgr->zones, raw, link);
raw->zmgr = zmgr;