From 1fe391fd40e6ec7581d2a1fad7c6406475ce3f0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Thu, 19 May 2022 11:20:21 +0200 Subject: [PATCH] Make all tasks to be bound to a thread Previously, tasks could be created either unbound or bound to a specific thread (worker loop). The unbound tasks would be assigned to a random thread every time isc_task_send() was called. Because there's no logic that would assign the task to the least busy worker, this just creates unpredictability. Instead of random assignment, bind all the previously unbound tasks to worker 0, which is guaranteed to exist. --- bin/dig/dighost.c | 2 +- bin/dnssec/dnssec-signzone.c | 4 +- bin/named/server.c | 2 +- bin/nsupdate/nsupdate.c | 2 +- bin/rndc/rndc.c | 2 +- bin/tests/system/pipelined/pipequeries.c | 2 +- bin/tests/system/tkey/keycreate.c | 2 +- bin/tests/system/tkey/keydelete.c | 2 +- bin/tools/mdig.c | 2 +- lib/dns/adb.c | 2 +- lib/dns/cache.c | 4 +- lib/dns/catz.c | 2 +- lib/dns/client.c | 2 +- lib/dns/nta.c | 2 +- lib/dns/resolver.c | 4 +- lib/dns/rpz.c | 2 +- lib/dns/tests/dnstest.c | 2 +- lib/dns/tests/keytable_test.c | 2 +- lib/dns/view.c | 2 +- lib/dns/zone.c | 10 ++--- lib/isc/include/isc/task.h | 40 ++++++++----------- lib/isc/task.c | 49 ++++++------------------ lib/isc/tests/isctest.c | 2 +- lib/isc/tests/task_test.c | 21 +++++----- lib/isc/tests/timer_test.c | 6 +-- lib/ns/client.c | 4 +- lib/ns/interfacemgr.c | 2 +- lib/ns/tests/nstest.c | 2 +- 28 files changed, 72 insertions(+), 108 deletions(-) diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index 2e3f2df5d8..528098a077 100644 --- a/bin/dig/dighost.c +++ b/bin/dig/dighost.c @@ -1392,7 +1392,7 @@ setup_libs(void) { isc_managers_create(mctx, 1, 0, &netmgr, &taskmgr, NULL); - result = isc_task_create(taskmgr, 0, &global_task); + result = isc_task_create(taskmgr, 0, &global_task, 0); check_result(result, "isc_task_create"); isc_task_setname(global_task, "dig", NULL); diff --git a/bin/dnssec/dnssec-signzone.c b/bin/dnssec/dnssec-signzone.c index 2a8e729821..66abc6c002 100644 --- a/bin/dnssec/dnssec-signzone.c +++ b/bin/dnssec/dnssec-signzone.c @@ -4001,7 +4001,7 @@ main(int argc, char *argv[]) { isc_managers_create(mctx, ntasks, 0, &netmgr, &taskmgr, NULL); main_task = NULL; - result = isc_task_create(taskmgr, 0, &main_task); + result = isc_task_create(taskmgr, 0, &main_task, 0); if (result != ISC_R_SUCCESS) { fatal("failed to create task: %s", isc_result_totext(result)); } @@ -4009,7 +4009,7 @@ main(int argc, char *argv[]) { tasks = isc_mem_get(mctx, ntasks * sizeof(isc_task_t *)); for (i = 0; i < (int)ntasks; i++) { tasks[i] = NULL; - result = isc_task_create(taskmgr, 0, &tasks[i]); + result = isc_task_create(taskmgr, 0, &tasks[i], i); if (result != ISC_R_SUCCESS) { fatal("failed to create task: %s", isc_result_totext(result)); diff --git a/bin/named/server.c b/bin/named/server.c index 49ec7cb4f6..84cc98419a 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -10067,7 +10067,7 @@ named_server_create(isc_mem_t *mctx, named_server_t **serverp) { * startup and shutdown of the server, as well as all exclusive * tasks. */ - CHECKFATAL(isc_task_create_bound(named_g_taskmgr, 0, &server->task, 0), + CHECKFATAL(isc_task_create(named_g_taskmgr, 0, &server->task, 0), "creating server task"); isc_task_setname(server->task, "server", server); isc_taskmgr_setexcltask(named_g_taskmgr, server->task); diff --git a/bin/nsupdate/nsupdate.c b/bin/nsupdate/nsupdate.c index 0982bd8a98..b57fe20bb2 100644 --- a/bin/nsupdate/nsupdate.c +++ b/bin/nsupdate/nsupdate.c @@ -911,7 +911,7 @@ setup_system(void) { result = dns_dispatchmgr_create(gmctx, netmgr, &dispatchmgr); check_result(result, "dns_dispatchmgr_create"); - result = isc_task_create(taskmgr, 0, &global_task); + result = isc_task_create(taskmgr, 0, &global_task, 0); check_result(result, "isc_task_create"); result = dst_lib_init(gmctx, NULL); diff --git a/bin/rndc/rndc.c b/bin/rndc/rndc.c index b9fbd87f0c..bd9afeac1a 100644 --- a/bin/rndc/rndc.c +++ b/bin/rndc/rndc.c @@ -1028,7 +1028,7 @@ main(int argc, char **argv) { isc_mem_create(&rndc_mctx); isc_managers_create(rndc_mctx, 1, 0, &netmgr, &taskmgr, NULL); - DO("create task", isc_task_create(taskmgr, 0, &rndc_task)); + DO("create task", isc_task_create(taskmgr, 0, &rndc_task, 0)); isc_log_create(rndc_mctx, &log, &logconfig); isc_log_setcontext(log); isc_log_settag(logconfig, progname); diff --git a/bin/tests/system/pipelined/pipequeries.c b/bin/tests/system/pipelined/pipequeries.c index 8324756454..5693846387 100644 --- a/bin/tests/system/pipelined/pipequeries.c +++ b/bin/tests/system/pipelined/pipequeries.c @@ -263,7 +263,7 @@ main(int argc, char *argv[]) { RUNCHECK(dst_lib_init(mctx, NULL)); isc_managers_create(mctx, 1, 0, &netmgr, &taskmgr, NULL); - RUNCHECK(isc_task_create(taskmgr, 0, &task)); + RUNCHECK(isc_task_create(taskmgr, 0, &task, 0)); RUNCHECK(dns_dispatchmgr_create(mctx, netmgr, &dispatchmgr)); RUNCHECK(dns_dispatch_createudp( diff --git a/bin/tests/system/tkey/keycreate.c b/bin/tests/system/tkey/keycreate.c index d03dffc5d5..83e0a38563 100644 --- a/bin/tests/system/tkey/keycreate.c +++ b/bin/tests/system/tkey/keycreate.c @@ -223,7 +223,7 @@ main(int argc, char *argv[]) { isc_managers_create(mctx, 1, 0, &netmgr, &taskmgr, NULL); - RUNCHECK(isc_task_create(taskmgr, 0, &task)); + RUNCHECK(isc_task_create(taskmgr, 0, &task, 0)); RUNCHECK(dns_dispatchmgr_create(mctx, netmgr, &dispatchmgr)); isc_sockaddr_any(&bind_any); diff --git a/bin/tests/system/tkey/keydelete.c b/bin/tests/system/tkey/keydelete.c index 4d32865510..bc9e18a7b5 100644 --- a/bin/tests/system/tkey/keydelete.c +++ b/bin/tests/system/tkey/keydelete.c @@ -167,7 +167,7 @@ main(int argc, char **argv) { isc_managers_create(mctx, 1, 0, &netmgr, &taskmgr, NULL); - RUNCHECK(isc_task_create(taskmgr, 0, &task)); + RUNCHECK(isc_task_create(taskmgr, 0, &task, 0)); RUNCHECK(dns_dispatchmgr_create(mctx, netmgr, &dispatchmgr)); isc_sockaddr_any(&bind_any); RUNCHECK(dns_dispatch_createudp(dispatchmgr, &bind_any, &dispatchv4)); diff --git a/bin/tools/mdig.c b/bin/tools/mdig.c index 725363d41c..ad4139ffee 100644 --- a/bin/tools/mdig.c +++ b/bin/tools/mdig.c @@ -2157,7 +2157,7 @@ main(int argc, char *argv[]) { } isc_managers_create(mctx, 1, 0, &netmgr, &taskmgr, NULL); - RUNCHECK(isc_task_create(taskmgr, 0, &task)); + RUNCHECK(isc_task_create(taskmgr, 0, &task, 0)); RUNCHECK(dns_dispatchmgr_create(mctx, netmgr, &dispatchmgr)); set_source_ports(dispatchmgr); diff --git a/lib/dns/adb.c b/lib/dns/adb.c index 5c5d1d714e..cb9539a778 100644 --- a/lib/dns/adb.c +++ b/lib/dns/adb.c @@ -2126,7 +2126,7 @@ dns_adb_create(isc_mem_t *mem, dns_view_t *view, isc_taskmgr_t *taskmgr, /* * Allocate an internal task. */ - result = isc_task_create(adb->taskmgr, 0, &adb->task); + result = isc_task_create(adb->taskmgr, 0, &adb->task, 0); if (result != ISC_R_SUCCESS) { goto free_lock; } diff --git a/lib/dns/cache.c b/lib/dns/cache.c index c7fa21d94f..011338e997 100644 --- a/lib/dns/cache.c +++ b/lib/dns/cache.c @@ -258,7 +258,7 @@ dns_cache_create(isc_mem_t *cmctx, isc_mem_t *hmctx, isc_taskmgr_t *taskmgr, } if (taskmgr != NULL) { dbtask = NULL; - result = isc_task_create(taskmgr, 1, &dbtask); + result = isc_task_create(taskmgr, 1, &dbtask, 0); if (result != ISC_R_SUCCESS) { goto cleanup_db; } @@ -470,7 +470,7 @@ cache_cleaner_init(dns_cache_t *cache, isc_taskmgr_t *taskmgr, } if (taskmgr != NULL && timermgr != NULL) { - result = isc_task_create(taskmgr, 1, &cleaner->task); + result = isc_task_create(taskmgr, 1, &cleaner->task, 0); if (result != ISC_R_SUCCESS) { UNEXPECTED_ERROR(__FILE__, __LINE__, "isc_task_create() failed: %s", diff --git a/lib/dns/catz.c b/lib/dns/catz.c index e14880bfd0..6007a1cab1 100644 --- a/lib/dns/catz.c +++ b/lib/dns/catz.c @@ -732,7 +732,7 @@ dns_catz_new_zones(dns_catz_zones_t **catzsp, dns_catz_zonemodmethods_t *zmm, new_zones->timermgr = timermgr; new_zones->taskmgr = taskmgr; - result = isc_task_create(taskmgr, 0, &new_zones->updater); + result = isc_task_create(taskmgr, 0, &new_zones->updater, 0); if (result != ISC_R_SUCCESS) { goto cleanup_ht; } diff --git a/lib/dns/client.c b/lib/dns/client.c index 8f4d13939b..675b78c8b3 100644 --- a/lib/dns/client.c +++ b/lib/dns/client.c @@ -286,7 +286,7 @@ dns_client_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr, isc_nm_t *nm, isc_mutex_init(&client->readylock); isc_condition_init(&client->ready); - result = isc_task_create(client->taskmgr, 0, &client->task); + result = isc_task_create(client->taskmgr, 0, &client->task, 0); if (result != ISC_R_SUCCESS) { goto cleanup_lock; } diff --git a/lib/dns/nta.c b/lib/dns/nta.c index c5d3d905a4..d6a2f61cf5 100644 --- a/lib/dns/nta.c +++ b/lib/dns/nta.c @@ -111,7 +111,7 @@ dns_ntatable_create(dns_view_t *view, isc_taskmgr_t *taskmgr, ntatable = isc_mem_get(view->mctx, sizeof(*ntatable)); ntatable->task = NULL; - result = isc_task_create(taskmgr, 0, &ntatable->task); + result = isc_task_create(taskmgr, 0, &ntatable->task, 0); if (result != ISC_R_SUCCESS) { goto cleanup_ntatable; } diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index be1f9200bd..08498c368d 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -10230,7 +10230,7 @@ dns_resolver_create(dns_view_t *view, isc_taskmgr_t *taskmgr, * Since we have a pool of tasks we bind them to task * queues to spread the load evenly */ - result = isc_task_create_bound(taskmgr, 0, &res->tasks[i], i); + result = isc_task_create(taskmgr, 0, &res->tasks[i], i); if (result != ISC_R_SUCCESS) { goto cleanup_tasks; } @@ -10260,7 +10260,7 @@ dns_resolver_create(dns_view_t *view, isc_taskmgr_t *taskmgr, isc_mutex_init(&res->lock); isc_mutex_init(&res->primelock); - result = isc_task_create(taskmgr, 0, &task); + result = isc_task_create(taskmgr, 0, &task, 0); if (result != ISC_R_SUCCESS) { goto cleanup_primelock; } diff --git a/lib/dns/rpz.c b/lib/dns/rpz.c index d76bd53683..20632eefe9 100644 --- a/lib/dns/rpz.c +++ b/lib/dns/rpz.c @@ -1476,7 +1476,7 @@ dns_rpz_new_zones(dns_rpz_zones_t **rpzsp, char *rps_cstr, size_t rps_cstr_size, goto cleanup_rbt; } - result = isc_task_create(taskmgr, 0, &rpzs->updater); + result = isc_task_create(taskmgr, 0, &rpzs->updater, 0); if (result != ISC_R_SUCCESS) { goto cleanup_task; } diff --git a/lib/dns/tests/dnstest.c b/lib/dns/tests/dnstest.c index 1ec9adfd1c..5f01e10d45 100644 --- a/lib/dns/tests/dnstest.c +++ b/lib/dns/tests/dnstest.c @@ -113,7 +113,7 @@ create_managers(void) { ncpus = isc_os_ncpus(); isc_managers_create(dt_mctx, ncpus, 0, &netmgr, &taskmgr, &timermgr); - CHECK(isc_task_create(taskmgr, 0, &maintask)); + CHECK(isc_task_create(taskmgr, 0, &maintask, 0)); return (ISC_R_SUCCESS); cleanup: diff --git a/lib/dns/tests/keytable_test.c b/lib/dns/tests/keytable_test.c index eaa375a12a..e08f94effd 100644 --- a/lib/dns/tests/keytable_test.c +++ b/lib/dns/tests/keytable_test.c @@ -603,7 +603,7 @@ nta_test(void **state) { result = dns_test_makeview("view", &myview); assert_int_equal(result, ISC_R_SUCCESS); - result = isc_task_create(taskmgr, 0, &myview->task); + result = isc_task_create(taskmgr, 0, &myview->task, 0); assert_int_equal(result, ISC_R_SUCCESS); result = dns_view_initsecroots(myview, dt_mctx); diff --git a/lib/dns/view.c b/lib/dns/view.c index 4bb96aa5a6..1669cd18a8 100644 --- a/lib/dns/view.c +++ b/lib/dns/view.c @@ -629,7 +629,7 @@ dns_view_createresolver(dns_view_t *view, isc_taskmgr_t *taskmgr, REQUIRE(!view->frozen); REQUIRE(view->resolver == NULL); - result = isc_task_create(taskmgr, 0, &view->task); + result = isc_task_create(taskmgr, 0, &view->task, 0); if (result != ISC_R_SUCCESS) { return (result); } diff --git a/lib/dns/zone.c b/lib/dns/zone.c index c9ddc21498..f9a7588442 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -18742,7 +18742,7 @@ dns_zonemgr_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr, isc_rwlock_init(&zmgr->urlock, 0, 0); /* Create a single task for queueing of SOA queries. */ - result = isc_task_create(taskmgr, 1, &zmgr->task); + result = isc_task_create(taskmgr, 1, &zmgr->task, 0); if (result != ISC_R_SUCCESS) { goto free_urlock; } @@ -18782,8 +18782,8 @@ dns_zonemgr_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr, zmgr->mctx, zmgr->workers * sizeof(zmgr->zonetasks[0])); memset(zmgr->zonetasks, 0, zmgr->workers * sizeof(zmgr->zonetasks[0])); for (size_t i = 0; i < zmgr->workers; i++) { - result = isc_task_create_bound(zmgr->taskmgr, 2, - &zmgr->zonetasks[i], i); + result = isc_task_create(zmgr->taskmgr, 2, &zmgr->zonetasks[i], + i); if (result != ISC_R_SUCCESS) { goto free_zonetasks; } @@ -18794,8 +18794,8 @@ dns_zonemgr_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr, zmgr->mctx, zmgr->workers * sizeof(zmgr->loadtasks[0])); memset(zmgr->loadtasks, 0, zmgr->workers * sizeof(zmgr->loadtasks[0])); for (size_t i = 0; i < zmgr->workers; i++) { - result = isc_task_create_bound(zmgr->taskmgr, UINT_MAX, - &zmgr->loadtasks[i], i); + result = isc_task_create(zmgr->taskmgr, UINT_MAX, + &zmgr->loadtasks[i], i); if (result != ISC_R_SUCCESS) { goto free_loadtasks; } diff --git a/lib/isc/include/isc/task.h b/lib/isc/include/isc/task.h index 703e7bff7f..d91ea1b604 100644 --- a/lib/isc/include/isc/task.h +++ b/lib/isc/include/isc/task.h @@ -47,10 +47,7 @@ * \section purge Purging and Unsending * * Events which have been queued for a task but not delivered may be removed - * from the task's event queue by purging or unsending. - * - * With both types, the caller specifies a matching pattern that selects - * events based upon their sender, type, and tag. + * from the task's event queue by purging the event. * * Purging calls isc_event_free() on the matching events. * @@ -92,16 +89,14 @@ ISC_LANG_BEGINDECLS *** Types ***/ -#define isc_task_create(m, q, t) \ - isc__task_create_bound(m, q, t, -1 ISC__TASKFILELINE) -#define isc_task_create_bound(m, q, t, i) \ - isc__task_create_bound(m, q, t, i ISC__TASKFILELINE) +#define isc_task_create(m, q, t, i) \ + isc__task_create(m, q, t, i ISC__TASKFILELINE) isc_result_t -isc__task_create_bound(isc_taskmgr_t *manager, unsigned int quantum, - isc_task_t **taskp, int tid ISC__TASKFLARG); +isc__task_create(isc_taskmgr_t *manager, unsigned int quantum, + isc_task_t **taskp, int tid ISC__TASKFLARG); /*%< - * Create a task, optionally bound to a particular tid. + * Create a task, bound to a particular thread id. * * Notes: * @@ -127,7 +122,6 @@ isc__task_create_bound(isc_taskmgr_t *manager, unsigned int quantum, * Returns: * *\li #ISC_R_SUCCESS - *\li #ISC_R_NOMEMORY *\li #ISC_R_UNEXPECTED *\li #ISC_R_SHUTTINGDOWN */ @@ -196,7 +190,7 @@ isc_task_detach(isc_task_t **taskp); void isc_task_send(isc_task_t *task, isc_event_t **eventp); /*%< - * Send '*event' to 'task', if task is idle try starting it on cpu 'c' + * Send '*event' to 'task'. * * Requires: * @@ -212,7 +206,7 @@ void isc_task_sendanddetach(isc_task_t **taskp, isc_event_t **eventp); /*%< * Send '*event' to '*taskp' and then detach '*taskp' from its - * task. If task is idle try starting it on cpu 'c' + * task. * * Requires: * @@ -239,15 +233,12 @@ isc_task_purgeevent(isc_task_t *task, isc_event_t *event); /*%< * Purge 'event' from a task's event queue. * - * XXXRTH: WARNING: This method may be removed before beta. - * * Notes: * - *\li If 'event' is on the task's event queue, it will be purged, - * unless it is marked as unpurgeable. 'event' does not have to be - * on the task's event queue; in fact, it can even be an invalid - * pointer. Purging only occurs if the event is actually on the task's - * event queue. + *\li If 'event' is on the task's event queue, it will be purged. 'event' + * does not have to be on the task's event queue; in fact, it can even be + * an invalid pointer. Purging only occurs if the event is actually on the + * task's event queue. * * \li Purging never changes the state of the task. * @@ -262,8 +253,7 @@ isc_task_purgeevent(isc_task_t *task, isc_event_t *event); * Returns: * *\li #true The event was purged. - *\li #false The event was not in the event queue, - * or was marked unpurgeable. + *\li #false The event was not in the event queue. */ void @@ -295,8 +285,8 @@ isc_task_getname(isc_task_t *task); * * Returns: *\li A non-NULL pointer to a null-terminated string. - * If the task has not been named, the string is - * empty. + * If the task has not been named, the string is + * empty. * */ diff --git a/lib/isc/task.c b/lib/isc/task.c index 75d42198c5..248d871b57 100644 --- a/lib/isc/task.c +++ b/lib/isc/task.c @@ -58,7 +58,7 @@ * locality on CPU. * * To make load even some tasks (from task pools) are bound to specific - * queues using isc_task_create_bound. This way load balancing between + * queues using isc_task_create. This way load balancing between * CPUs/queues happens on the higher layer. */ @@ -118,7 +118,6 @@ struct isc_task { isc_time_t tnow; char name[16]; void *tag; - bool bound; /* Protected by atomics */ atomic_bool shuttingdown; /* Locked by task manager lock. */ @@ -198,18 +197,22 @@ task_destroy(isc_task_t *task) { } isc_result_t -isc__task_create_bound(isc_taskmgr_t *manager, unsigned int quantum, - isc_task_t **taskp, int tid ISC__TASKFLARG) { +isc__task_create(isc_taskmgr_t *manager, unsigned int quantum, + isc_task_t **taskp, int tid ISC__TASKFLARG) { isc_task_t *task = NULL; bool exiting; REQUIRE(VALID_MANAGER(manager)); REQUIRE(taskp != NULL && *taskp == NULL); + REQUIRE(tid >= 0 && tid < (int)manager->nworkers); XTRACE("isc_task_create"); task = isc_mem_get(manager->mctx, sizeof(*task)); - *task = (isc_task_t){ 0 }; + *task = (isc_task_t){ + .state = task_state_idle, + .tid = tid, + }; #if TASKMGR_TRACE strlcpy(task->func, func, sizeof(task->func)); @@ -221,34 +224,14 @@ isc__task_create_bound(isc_taskmgr_t *manager, unsigned int quantum, isc_taskmgr_attach(manager, &task->manager); - if (tid == -1) { - /* - * Task is not pinned to a queue, it's tid will be - * randomly chosen when first task will be sent to it. - */ - task->bound = false; - task->tid = -1; - } else { - /* - * Task is pinned to a queue, it'll always be run - * by a specific thread. - */ - task->bound = true; - task->tid = tid % task->manager->nworkers; - } - isc_mutex_init(&task->lock); - task->state = task_state_idle; isc_refcount_init(&task->references, 1); INIT_LIST(task->events); - task->nevents = 0; task->quantum = (quantum > 0) ? quantum : manager->default_quantum; atomic_init(&task->shuttingdown, false); - task->now = 0; isc_time_settoepoch(&task->tnow); memset(task->name, 0, sizeof(task->name)); - task->tag = NULL; INIT_LINK(task, link); task->magic = TASK_MAGIC; @@ -304,9 +287,6 @@ task_ready(isc_task_t *task) { isc_task_attach(task, &(isc_task_t *){ NULL }); LOCK(&task->lock); - if (task->tid < 0) { - task->tid = (int)isc_random_uniform(manager->nworkers); - } isc_nm_task_enqueue(manager->netmgr, task, task->tid); UNLOCK(&task->lock); } @@ -358,10 +338,6 @@ task_send(isc_task_t *task, isc_event_t **eventp) { if (task->state == task_state_idle) { was_idle = true; - if (!task->bound) { - task->tid = (int)isc_random_uniform( - task->manager->nworkers); - } INSIST(EMPTY(task->events)); task->state = task_state_ready; } @@ -438,11 +414,10 @@ isc_task_purgeevent(isc_task_t *task, isc_event_t *event) { REQUIRE(VALID_TASK(task)); /* - * If 'event' is on the task's event queue, it will be purged, - * unless it is marked as unpurgeable. 'event' does not have to be - * on the task's event queue; in fact, it can even be an invalid - * pointer. Purging only occurs if the event is actually on the task's - * event queue. + * If 'event' is on the task's event queue, it will be purged, 'event' + * does not have to be on the task's event queue; in fact, it can even + * be an invalid pointer. Purging only occurs if the event is actually + * on the task's event queue. * * Purging never changes the state of the task. */ diff --git a/lib/isc/tests/isctest.c b/lib/isc/tests/isctest.c index ad8fa2ad60..31690357c9 100644 --- a/lib/isc/tests/isctest.c +++ b/lib/isc/tests/isctest.c @@ -79,7 +79,7 @@ create_managers(unsigned int workers) { isc_managers_create(test_mctx, workers, 0, &netmgr, &taskmgr, &timermgr); - CHECK(isc_task_create_bound(taskmgr, 0, &maintask, 0)); + CHECK(isc_task_create(taskmgr, 0, &maintask, 0)); isc_taskmgr_setexcltask(taskmgr, maintask); return (ISC_R_SUCCESS); diff --git a/lib/isc/tests/task_test.c b/lib/isc/tests/task_test.c index b19fb9d985..b06e7158af 100644 --- a/lib/isc/tests/task_test.c +++ b/lib/isc/tests/task_test.c @@ -131,7 +131,7 @@ create_task(void **state) { UNUSED(state); - result = isc_task_create(taskmgr, 0, &task); + result = isc_task_create(taskmgr, 0, &task, 0); assert_int_equal(result, ISC_R_SUCCESS); isc_task_detach(&task); @@ -153,7 +153,7 @@ all_events(void **state) { atomic_init(&a, 0); atomic_init(&b, 0); - result = isc_task_create(taskmgr, 0, &task); + result = isc_task_create(taskmgr, 0, &task, 0); assert_int_equal(result, ISC_R_SUCCESS); /* First event */ @@ -240,13 +240,13 @@ basic(void **state) { UNUSED(state); - result = isc_task_create(taskmgr, 0, &task1); + result = isc_task_create(taskmgr, 0, &task1, 0); assert_int_equal(result, ISC_R_SUCCESS); - result = isc_task_create(taskmgr, 0, &task2); + result = isc_task_create(taskmgr, 0, &task2, 0); assert_int_equal(result, ISC_R_SUCCESS); - result = isc_task_create(taskmgr, 0, &task3); + result = isc_task_create(taskmgr, 0, &task3, 0); assert_int_equal(result, ISC_R_SUCCESS); - result = isc_task_create(taskmgr, 0, &task4); + result = isc_task_create(taskmgr, 0, &task4, 0); assert_int_equal(result, ISC_R_SUCCESS); isc_interval_set(&interval, 1, 0); @@ -365,13 +365,12 @@ task_exclusive(void **state) { if (i == 6) { /* task chosen from the middle of the range */ - result = isc_task_create_bound(taskmgr, 0, &tasks[i], - 0); + result = isc_task_create(taskmgr, 0, &tasks[i], 0); assert_int_equal(result, ISC_R_SUCCESS); isc_taskmgr_setexcltask(taskmgr, tasks[6]); } else { - result = isc_task_create(taskmgr, 0, &tasks[i]); + result = isc_task_create(taskmgr, 0, &tasks[i], 0); assert_int_equal(result, ISC_R_SUCCESS); } @@ -415,7 +414,7 @@ maxtask_cb(isc_task_t *task, isc_event_t *event) { /* * Create a new task and forward the message. */ - result = isc_task_create(taskmgr, 0, &task); + result = isc_task_create(taskmgr, 0, &task, 0); assert_int_equal(result, ISC_R_SUCCESS); isc_task_send(task, &event); @@ -513,7 +512,7 @@ try_purgeevent(void) { atomic_init(&done, false); eventcnt = 0; - result = isc_task_create(taskmgr, 0, &task); + result = isc_task_create(taskmgr, 0, &task, 0); assert_int_equal(result, ISC_R_SUCCESS); /* diff --git a/lib/isc/tests/timer_test.c b/lib/isc/tests/timer_test.c index 685ce6973b..b91e0ac15f 100644 --- a/lib/isc/tests/timer_test.c +++ b/lib/isc/tests/timer_test.c @@ -114,7 +114,7 @@ setup_test(isc_timertype_t timertype, isc_interval_t *interval, LOCK(&mx); - result = isc_task_create(taskmgr, 0, &task); + result = isc_task_create(taskmgr, 0, &task, 0); assert_int_equal(result, ISC_R_SUCCESS); isc_mutex_lock(&lasttime_mx); @@ -493,10 +493,10 @@ purge(void **state) { seconds = 1; nanoseconds = 0; - result = isc_task_create(taskmgr, 0, &task1); + result = isc_task_create(taskmgr, 0, &task1, 0); assert_int_equal(result, ISC_R_SUCCESS); - result = isc_task_create(taskmgr, 0, &task2); + result = isc_task_create(taskmgr, 0, &task2, 0); assert_int_equal(result, ISC_R_SUCCESS); isc_interval_set(&interval, seconds, 0); diff --git a/lib/ns/client.c b/lib/ns/client.c index edb89604a6..7596bb62e5 100644 --- a/lib/ns/client.c +++ b/lib/ns/client.c @@ -2436,8 +2436,8 @@ ns_clientmgr_create(ns_server_t *sctx, isc_taskmgr_t *taskmgr, dns_aclenv_attach(aclenv, &manager->aclenv); - result = isc_task_create_bound(manager->taskmgr, 20, &manager->task, - manager->tid); + result = isc_task_create(manager->taskmgr, 20, &manager->task, + manager->tid); RUNTIME_CHECK(result == ISC_R_SUCCESS); isc_task_setname(manager->task, "clientmgr", NULL); diff --git a/lib/ns/interfacemgr.c b/lib/ns/interfacemgr.c index 90268e94e4..b399fe9f55 100644 --- a/lib/ns/interfacemgr.c +++ b/lib/ns/interfacemgr.c @@ -302,7 +302,7 @@ ns_interfacemgr_create(isc_mem_t *mctx, ns_server_t *sctx, isc_mutex_init(&mgr->lock); - result = isc_task_create_bound(taskmgr, 0, &mgr->task, 0); + result = isc_task_create(taskmgr, 0, &mgr->task, 0); if (result != ISC_R_SUCCESS) { goto cleanup_lock; } diff --git a/lib/ns/tests/nstest.c b/lib/ns/tests/nstest.c index 076d01f775..6afaed065f 100644 --- a/lib/ns/tests/nstest.c +++ b/lib/ns/tests/nstest.c @@ -228,7 +228,7 @@ create_managers(void) { int ncpus = isc_os_ncpus(); isc_managers_create(mctx, ncpus, 0, &netmgr, &taskmgr, &timermgr); - CHECK(isc_task_create_bound(taskmgr, 0, &maintask, 0)); + CHECK(isc_task_create(taskmgr, 0, &maintask, 0)); isc_taskmgr_setexcltask(taskmgr, maintask); CHECK(ns_server_create(mctx, matchview, &sctx));