Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bbcb9d6669 | ||
|
|
f0f73d8ad4 | ||
|
|
4dd7e8c2fe | ||
|
|
91788ada31 |
+1
-1
@@ -1623,7 +1623,7 @@ main(int argc, char *argv[]) {
|
|||||||
fatal("failed to create mctx");
|
fatal("failed to create mctx");
|
||||||
|
|
||||||
CHECK(isc_appctx_create(mctx, &actx));
|
CHECK(isc_appctx_create(mctx, &actx));
|
||||||
CHECK(isc_taskmgr_createinctx(mctx, actx, 1, 0, &taskmgr));
|
CHECK(isc_taskmgr_createinctx(mctx, actx, 1, &taskmgr));
|
||||||
CHECK(isc_socketmgr_createinctx(mctx, actx, &socketmgr));
|
CHECK(isc_socketmgr_createinctx(mctx, actx, &socketmgr));
|
||||||
CHECK(isc_timermgr_createinctx(mctx, actx, &timermgr));
|
CHECK(isc_timermgr_createinctx(mctx, actx, &timermgr));
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1363,7 +1363,7 @@ setup_libs(void) {
|
|||||||
|
|
||||||
isc_log_setdebuglevel(lctx, 0);
|
isc_log_setdebuglevel(lctx, 0);
|
||||||
|
|
||||||
result = isc_taskmgr_create(mctx, 1, 0, &taskmgr);
|
result = isc_taskmgr_create(mctx, 1, &taskmgr);
|
||||||
check_result(result, "isc_taskmgr_create");
|
check_result(result, "isc_taskmgr_create");
|
||||||
|
|
||||||
result = isc_task_create(taskmgr, 0, &global_task);
|
result = isc_task_create(taskmgr, 0, &global_task);
|
||||||
|
|||||||
@@ -3853,7 +3853,7 @@ main(int argc, char *argv[]) {
|
|||||||
print_time(outfp);
|
print_time(outfp);
|
||||||
print_version(outfp);
|
print_version(outfp);
|
||||||
|
|
||||||
result = isc_taskmgr_create(mctx, ntasks, 0, &taskmgr);
|
result = isc_taskmgr_create(mctx, ntasks, &taskmgr);
|
||||||
if (result != ISC_R_SUCCESS)
|
if (result != ISC_R_SUCCESS)
|
||||||
fatal("failed to create task manager: %s",
|
fatal("failed to create task manager: %s",
|
||||||
isc_result_totext(result));
|
isc_result_totext(result));
|
||||||
|
|||||||
+1
-1
@@ -803,7 +803,7 @@ create_managers(void) {
|
|||||||
"using %u UDP listener%s per interface",
|
"using %u UDP listener%s per interface",
|
||||||
named_g_udpdisp, named_g_udpdisp == 1 ? "" : "s");
|
named_g_udpdisp, named_g_udpdisp == 1 ? "" : "s");
|
||||||
|
|
||||||
result = isc_taskmgr_create(named_g_mctx, named_g_cpus, 0,
|
result = isc_taskmgr_create(named_g_mctx, named_g_cpus,
|
||||||
&named_g_taskmgr);
|
&named_g_taskmgr);
|
||||||
if (result != ISC_R_SUCCESS) {
|
if (result != ISC_R_SUCCESS) {
|
||||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||||
|
|||||||
@@ -885,7 +885,7 @@ setup_system(void) {
|
|||||||
result = isc_timermgr_create(gmctx, &timermgr);
|
result = isc_timermgr_create(gmctx, &timermgr);
|
||||||
check_result(result, "dns_timermgr_create");
|
check_result(result, "dns_timermgr_create");
|
||||||
|
|
||||||
result = isc_taskmgr_create(gmctx, 1, 0, &taskmgr);
|
result = isc_taskmgr_create(gmctx, 1, &taskmgr);
|
||||||
check_result(result, "isc_taskmgr_create");
|
check_result(result, "isc_taskmgr_create");
|
||||||
|
|
||||||
result = isc_task_create(taskmgr, 0, &global_task);
|
result = isc_task_create(taskmgr, 0, &global_task);
|
||||||
|
|||||||
+1
-1
@@ -934,7 +934,7 @@ main(int argc, char **argv) {
|
|||||||
|
|
||||||
DO("create memory context", isc_mem_create(0, 0, &rndc_mctx));
|
DO("create memory context", isc_mem_create(0, 0, &rndc_mctx));
|
||||||
DO("create socket manager", isc_socketmgr_create(rndc_mctx, &socketmgr));
|
DO("create socket manager", isc_socketmgr_create(rndc_mctx, &socketmgr));
|
||||||
DO("create task manager", isc_taskmgr_create(rndc_mctx, 1, 0, &taskmgr));
|
DO("create task manager", isc_taskmgr_create(rndc_mctx, 1, &taskmgr));
|
||||||
DO("create task", isc_task_create(taskmgr, 0, &task));
|
DO("create task", isc_task_create(taskmgr, 0, &task));
|
||||||
|
|
||||||
DO("create logging context", isc_log_create(rndc_mctx, &log, &logconfig));
|
DO("create logging context", isc_log_create(rndc_mctx, &log, &logconfig));
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ create_managers(void) {
|
|||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
|
|
||||||
taskmgr = NULL;
|
taskmgr = NULL;
|
||||||
result = isc_taskmgr_create(mctx, 5, 0, &taskmgr);
|
result = isc_taskmgr_create(mctx, 5, &taskmgr);
|
||||||
check_result(result, "isc_taskmgr_create");
|
check_result(result, "isc_taskmgr_create");
|
||||||
|
|
||||||
timermgr = NULL;
|
timermgr = NULL;
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
taskmgr = NULL;
|
taskmgr = NULL;
|
||||||
RUNTIME_CHECK(isc_taskmgr_create(mctx, workers, 0, &taskmgr)
|
RUNTIME_CHECK(isc_taskmgr_create(mctx, workers, &taskmgr)
|
||||||
== ISC_R_SUCCESS);
|
== ISC_R_SUCCESS);
|
||||||
task = NULL;
|
task = NULL;
|
||||||
RUNTIME_CHECK(isc_task_create(taskmgr, 0, &task)
|
RUNTIME_CHECK(isc_task_create(taskmgr, 0, &task)
|
||||||
|
|||||||
@@ -228,7 +228,7 @@ main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
taskmgr = NULL;
|
taskmgr = NULL;
|
||||||
RUNTIME_CHECK(isc_taskmgr_create(mctx, workers, 0, &taskmgr) ==
|
RUNTIME_CHECK(isc_taskmgr_create(mctx, workers, &taskmgr) ==
|
||||||
ISC_R_SUCCESS);
|
ISC_R_SUCCESS);
|
||||||
task = NULL;
|
task = NULL;
|
||||||
RUNTIME_CHECK(isc_task_create(taskmgr, 0, &task) ==
|
RUNTIME_CHECK(isc_task_create(taskmgr, 0, &task) ==
|
||||||
|
|||||||
@@ -472,7 +472,7 @@ main(int argc, char *argv[]) {
|
|||||||
RUNCHECK(dst_lib_init(mctx, NULL));
|
RUNCHECK(dst_lib_init(mctx, NULL));
|
||||||
|
|
||||||
taskmgr = NULL;
|
taskmgr = NULL;
|
||||||
RUNCHECK(isc_taskmgr_create(mctx, 1, 0, &taskmgr));
|
RUNCHECK(isc_taskmgr_create(mctx, 1, &taskmgr));
|
||||||
task = NULL;
|
task = NULL;
|
||||||
RUNCHECK(isc_task_create(taskmgr, 0, &task));
|
RUNCHECK(isc_task_create(taskmgr, 0, &task));
|
||||||
timermgr = NULL;
|
timermgr = NULL;
|
||||||
|
|||||||
@@ -104,8 +104,7 @@ main(int argc, char *argv[]) {
|
|||||||
isc_interval_set(&linterval, 1, 0);
|
isc_interval_set(&linterval, 1, 0);
|
||||||
|
|
||||||
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
|
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
|
||||||
RUNTIME_CHECK(isc_taskmgr_create(mctx, 3, 0, &taskmgr) ==
|
RUNTIME_CHECK(isc_taskmgr_create(mctx, 3, &taskmgr) == ISC_R_SUCCESS);
|
||||||
ISC_R_SUCCESS);
|
|
||||||
RUNTIME_CHECK(isc_timermgr_create(mctx, &timermgr) ==
|
RUNTIME_CHECK(isc_timermgr_create(mctx, &timermgr) ==
|
||||||
ISC_R_SUCCESS);
|
ISC_R_SUCCESS);
|
||||||
RUNTIME_CHECK(isc_task_create(taskmgr, 0, &g_task) ==
|
RUNTIME_CHECK(isc_task_create(taskmgr, 0, &g_task) ==
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ main(int argc, char *argv[]) {
|
|||||||
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
|
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
|
||||||
mctx2 = NULL;
|
mctx2 = NULL;
|
||||||
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx2) == ISC_R_SUCCESS);
|
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx2) == ISC_R_SUCCESS);
|
||||||
RUNTIME_CHECK(isc_taskmgr_create(mctx, workers, 0, &task_manager) ==
|
RUNTIME_CHECK(isc_taskmgr_create(mctx, workers, &task_manager) ==
|
||||||
ISC_R_SUCCESS);
|
ISC_R_SUCCESS);
|
||||||
RUNTIME_CHECK(isc_timermgr_create(mctx, &timer_manager) ==
|
RUNTIME_CHECK(isc_timermgr_create(mctx, &timer_manager) ==
|
||||||
ISC_R_SUCCESS);
|
ISC_R_SUCCESS);
|
||||||
|
|||||||
@@ -228,8 +228,7 @@ main(int argc, char *argv[]) {
|
|||||||
dst_result_register();
|
dst_result_register();
|
||||||
|
|
||||||
taskmgr = NULL;
|
taskmgr = NULL;
|
||||||
RUNTIME_CHECK(isc_taskmgr_create(mctx, 2, 0, &taskmgr) ==
|
RUNTIME_CHECK(isc_taskmgr_create(mctx, 2, &taskmgr) == ISC_R_SUCCESS);
|
||||||
ISC_R_SUCCESS);
|
|
||||||
task1 = NULL;
|
task1 = NULL;
|
||||||
RUNTIME_CHECK(isc_task_create(taskmgr, 0, &task1) == ISC_R_SUCCESS);
|
RUNTIME_CHECK(isc_task_create(taskmgr, 0, &task1) == ISC_R_SUCCESS);
|
||||||
|
|
||||||
|
|||||||
@@ -297,7 +297,7 @@ main(int argc, char *argv[]) {
|
|||||||
* The task manager is independent (other than memory context)
|
* The task manager is independent (other than memory context)
|
||||||
*/
|
*/
|
||||||
manager = NULL;
|
manager = NULL;
|
||||||
RUNTIME_CHECK(isc_taskmgr_create(mctx, workers, 0, &manager) ==
|
RUNTIME_CHECK(isc_taskmgr_create(mctx, workers, &manager) ==
|
||||||
ISC_R_SUCCESS);
|
ISC_R_SUCCESS);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
|
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
|
||||||
|
|
||||||
RUNTIME_CHECK(isc_taskmgr_create(mctx, workers, 0, &manager) ==
|
RUNTIME_CHECK(isc_taskmgr_create(mctx, workers, &manager) ==
|
||||||
ISC_R_SUCCESS);
|
ISC_R_SUCCESS);
|
||||||
|
|
||||||
RUNTIME_CHECK(isc_task_create(manager, 0, &t1) == ISC_R_SUCCESS);
|
RUNTIME_CHECK(isc_task_create(manager, 0, &t1) == ISC_R_SUCCESS);
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ main(int argc, char *argv[]) {
|
|||||||
printf("%u workers\n", workers);
|
printf("%u workers\n", workers);
|
||||||
|
|
||||||
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx1) == ISC_R_SUCCESS);
|
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx1) == ISC_R_SUCCESS);
|
||||||
RUNTIME_CHECK(isc_taskmgr_create(mctx1, workers, 0, &manager) ==
|
RUNTIME_CHECK(isc_taskmgr_create(mctx1, workers, &manager) ==
|
||||||
ISC_R_SUCCESS);
|
ISC_R_SUCCESS);
|
||||||
RUNTIME_CHECK(isc_timermgr_create(mctx1, &timgr) == ISC_R_SUCCESS);
|
RUNTIME_CHECK(isc_timermgr_create(mctx1, &timgr) == ISC_R_SUCCESS);
|
||||||
|
|
||||||
|
|||||||
@@ -284,7 +284,7 @@ main(int argc, char **argv) {
|
|||||||
|
|
||||||
RUNTIME_CHECK(isc_app_start() == ISC_R_SUCCESS);
|
RUNTIME_CHECK(isc_app_start() == ISC_R_SUCCESS);
|
||||||
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
|
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
|
||||||
RUNTIME_CHECK(isc_taskmgr_create(mctx, 2, 0, &taskmgr) ==
|
RUNTIME_CHECK(isc_taskmgr_create(mctx, 2, &taskmgr) ==
|
||||||
ISC_R_SUCCESS);
|
ISC_R_SUCCESS);
|
||||||
RUNTIME_CHECK(isc_timermgr_create(mctx, &timermgr) == ISC_R_SUCCESS);
|
RUNTIME_CHECK(isc_timermgr_create(mctx, &timermgr) == ISC_R_SUCCESS);
|
||||||
RUNTIME_CHECK(isc_socketmgr_create(mctx, &socketmgr) == ISC_R_SUCCESS);
|
RUNTIME_CHECK(isc_socketmgr_create(mctx, &socketmgr) == ISC_R_SUCCESS);
|
||||||
|
|||||||
@@ -279,7 +279,7 @@ main(int argc, char *argv[]) {
|
|||||||
RUNCHECK(dst_lib_init(mctx, NULL));
|
RUNCHECK(dst_lib_init(mctx, NULL));
|
||||||
|
|
||||||
taskmgr = NULL;
|
taskmgr = NULL;
|
||||||
RUNCHECK(isc_taskmgr_create(mctx, 1, 0, &taskmgr));
|
RUNCHECK(isc_taskmgr_create(mctx, 1, &taskmgr));
|
||||||
task = NULL;
|
task = NULL;
|
||||||
RUNCHECK(isc_task_create(taskmgr, 0, &task));
|
RUNCHECK(isc_task_create(taskmgr, 0, &task));
|
||||||
timermgr = NULL;
|
timermgr = NULL;
|
||||||
|
|||||||
@@ -239,7 +239,7 @@ main(int argc, char *argv[]) {
|
|||||||
RUNCHECK(dst_lib_init(mctx, NULL));
|
RUNCHECK(dst_lib_init(mctx, NULL));
|
||||||
|
|
||||||
taskmgr = NULL;
|
taskmgr = NULL;
|
||||||
RUNCHECK(isc_taskmgr_create(mctx, 1, 0, &taskmgr));
|
RUNCHECK(isc_taskmgr_create(mctx, 1, &taskmgr));
|
||||||
task = NULL;
|
task = NULL;
|
||||||
RUNCHECK(isc_task_create(taskmgr, 0, &task));
|
RUNCHECK(isc_task_create(taskmgr, 0, &task));
|
||||||
timermgr = NULL;
|
timermgr = NULL;
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ main(int argc, char **argv) {
|
|||||||
RUNCHECK(dst_lib_init(mctx, NULL));
|
RUNCHECK(dst_lib_init(mctx, NULL));
|
||||||
|
|
||||||
taskmgr = NULL;
|
taskmgr = NULL;
|
||||||
RUNCHECK(isc_taskmgr_create(mctx, 1, 0, &taskmgr));
|
RUNCHECK(isc_taskmgr_create(mctx, 1, &taskmgr));
|
||||||
task = NULL;
|
task = NULL;
|
||||||
RUNCHECK(isc_task_create(taskmgr, 0, &task));
|
RUNCHECK(isc_task_create(taskmgr, 0, &task));
|
||||||
timermgr = NULL;
|
timermgr = NULL;
|
||||||
|
|||||||
+1
-1
@@ -1981,7 +1981,7 @@ main(int argc, char *argv[]) {
|
|||||||
fatal("can't choose between IPv4 and IPv6");
|
fatal("can't choose between IPv4 and IPv6");
|
||||||
|
|
||||||
taskmgr = NULL;
|
taskmgr = NULL;
|
||||||
RUNCHECK(isc_taskmgr_create(mctx, 1, 0, &taskmgr));
|
RUNCHECK(isc_taskmgr_create(mctx, 1, &taskmgr));
|
||||||
task = NULL;
|
task = NULL;
|
||||||
RUNCHECK(isc_task_create(taskmgr, 0, &task));
|
RUNCHECK(isc_task_create(taskmgr, 0, &task));
|
||||||
timermgr = NULL;
|
timermgr = NULL;
|
||||||
|
|||||||
+3
-3
@@ -64,9 +64,9 @@
|
|||||||
#define MAX_RESTARTS 16
|
#define MAX_RESTARTS 16
|
||||||
|
|
||||||
#ifdef TUNE_LARGE
|
#ifdef TUNE_LARGE
|
||||||
#define RESOLVER_NTASKS 523
|
#define RESOLVER_NTASKS 24
|
||||||
#else
|
#else
|
||||||
#define RESOLVER_NTASKS 31
|
#define RESOLVER_NTASKS 48
|
||||||
#endif /* TUNE_LARGE */
|
#endif /* TUNE_LARGE */
|
||||||
|
|
||||||
/*%
|
/*%
|
||||||
@@ -379,7 +379,7 @@ dns_client_create(dns_client_t **clientp, unsigned int options) {
|
|||||||
result = isc_app_ctxstart(actx);
|
result = isc_app_ctxstart(actx);
|
||||||
if (result != ISC_R_SUCCESS)
|
if (result != ISC_R_SUCCESS)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
result = isc_taskmgr_createinctx(mctx, actx, 1, 0, &taskmgr);
|
result = isc_taskmgr_createinctx(mctx, actx, 1, &taskmgr);
|
||||||
if (result != ISC_R_SUCCESS)
|
if (result != ISC_R_SUCCESS)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
result = isc_socketmgr_createinctx(mctx, actx, &socketmgr);
|
result = isc_socketmgr_createinctx(mctx, actx, &socketmgr);
|
||||||
|
|||||||
+1
-1
@@ -2468,7 +2468,7 @@ dns_dispatch_createtcp(dns_dispatchmgr_t *mgr, isc_socket_t *sock,
|
|||||||
|
|
||||||
disp->ntasks = 1;
|
disp->ntasks = 1;
|
||||||
disp->task[0] = NULL;
|
disp->task[0] = NULL;
|
||||||
result = isc_task_create(taskmgr, 50, &disp->task[0]);
|
result = isc_task_create(taskmgr, 0, &disp->task[0]);
|
||||||
if (result != ISC_R_SUCCESS)
|
if (result != ISC_R_SUCCESS)
|
||||||
goto kill_socket;
|
goto kill_socket;
|
||||||
|
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ create_managers(void) {
|
|||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
ncpus = isc_os_ncpus();
|
ncpus = isc_os_ncpus();
|
||||||
|
|
||||||
CHECK(isc_taskmgr_create(mctx, ncpus, 0, &taskmgr));
|
CHECK(isc_taskmgr_create(mctx, ncpus, &taskmgr));
|
||||||
CHECK(isc_timermgr_create(mctx, &timermgr));
|
CHECK(isc_timermgr_create(mctx, &timermgr));
|
||||||
CHECK(isc_socketmgr_create(mctx, &socketmgr));
|
CHECK(isc_socketmgr_create(mctx, &socketmgr));
|
||||||
CHECK(isc_task_create(taskmgr, 0, &maintask));
|
CHECK(isc_task_create(taskmgr, 0, &maintask));
|
||||||
|
|||||||
+1
-1
@@ -104,7 +104,7 @@ ctxs_init(isc_mem_t **mctxp, isc_appctx_t **actxp,
|
|||||||
if (result != ISC_R_SUCCESS)
|
if (result != ISC_R_SUCCESS)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
result = isc_taskmgr_createinctx(*mctxp, *actxp, 1, 0, taskmgrp);
|
result = isc_taskmgr_createinctx(*mctxp, *actxp, 1, taskmgrp);
|
||||||
if (result != ISC_R_SUCCESS)
|
if (result != ISC_R_SUCCESS)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
|
|||||||
@@ -631,11 +631,10 @@ isc_task_privilege(isc_task_t *task);
|
|||||||
|
|
||||||
isc_result_t
|
isc_result_t
|
||||||
isc_taskmgr_createinctx(isc_mem_t *mctx, isc_appctx_t *actx,
|
isc_taskmgr_createinctx(isc_mem_t *mctx, isc_appctx_t *actx,
|
||||||
unsigned int workers, unsigned int default_quantum,
|
unsigned int workers, isc_taskmgr_t **managerp);
|
||||||
isc_taskmgr_t **managerp);
|
|
||||||
isc_result_t
|
isc_result_t
|
||||||
isc_taskmgr_create(isc_mem_t *mctx, unsigned int workers,
|
isc_taskmgr_create(isc_mem_t *mctx, unsigned int workers,
|
||||||
unsigned int default_quantum, isc_taskmgr_t **managerp);
|
isc_taskmgr_t **managerp);
|
||||||
/*%<
|
/*%<
|
||||||
* Create a new task manager. isc_taskmgr_createinctx() also associates
|
* Create a new task manager. isc_taskmgr_createinctx() also associates
|
||||||
* the new manager with the specified application context.
|
* the new manager with the specified application context.
|
||||||
@@ -648,10 +647,6 @@ isc_taskmgr_create(isc_mem_t *mctx, unsigned int workers,
|
|||||||
* create 'workers' threads, but if at least one thread creation
|
* create 'workers' threads, but if at least one thread creation
|
||||||
* succeeds, isc_taskmgr_create() may return ISC_R_SUCCESS.
|
* succeeds, isc_taskmgr_create() may return ISC_R_SUCCESS.
|
||||||
*
|
*
|
||||||
*\li If 'default_quantum' is non-zero, then it will be used as the default
|
|
||||||
* quantum value when tasks are created. If zero, then an implementation
|
|
||||||
* defined default quantum will be used.
|
|
||||||
*
|
|
||||||
* Requires:
|
* Requires:
|
||||||
*
|
*
|
||||||
*\li 'mctx' is a valid memory context.
|
*\li 'mctx' is a valid memory context.
|
||||||
|
|||||||
+44
-64
@@ -134,6 +134,8 @@ struct isc__taskqueue {
|
|||||||
isc_condition_t work_available;
|
isc_condition_t work_available;
|
||||||
isc_thread_t thread;
|
isc_thread_t thread;
|
||||||
unsigned int threadid;
|
unsigned int threadid;
|
||||||
|
unsigned int tasks_waiting;
|
||||||
|
bool running;
|
||||||
isc__taskmgr_t *manager;
|
isc__taskmgr_t *manager;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -145,13 +147,10 @@ struct isc__taskmgr {
|
|||||||
isc_mutex_t halt_lock;
|
isc_mutex_t halt_lock;
|
||||||
isc_condition_t halt_cond;
|
isc_condition_t halt_cond;
|
||||||
unsigned int workers;
|
unsigned int workers;
|
||||||
atomic_uint_fast32_t tasks_running;
|
|
||||||
atomic_uint_fast32_t tasks_ready;
|
|
||||||
atomic_uint_fast32_t curq;
|
atomic_uint_fast32_t curq;
|
||||||
isc__taskqueue_t *queues;
|
isc__taskqueue_t *queues;
|
||||||
|
|
||||||
/* Locked by task manager lock. */
|
/* Locked by task manager lock. */
|
||||||
unsigned int default_quantum;
|
|
||||||
LIST(isc__task_t) tasks;
|
LIST(isc__task_t) tasks;
|
||||||
isc_taskmgrmode_t mode;
|
isc_taskmgrmode_t mode;
|
||||||
bool pause_requested;
|
bool pause_requested;
|
||||||
@@ -176,7 +175,17 @@ void
|
|||||||
isc__taskmgr_resume(isc_taskmgr_t *manager0);
|
isc__taskmgr_resume(isc_taskmgr_t *manager0);
|
||||||
|
|
||||||
|
|
||||||
#define DEFAULT_DEFAULT_QUANTUM 25
|
/*
|
||||||
|
* Unless specified otherwise when creating task we normally run
|
||||||
|
* DEFAULT_QUANTUM events from a task in a single worker loop.
|
||||||
|
* If there are more than CONGESTED_TASK_LIMIT tasks waiting in the same queue
|
||||||
|
* we switch to CONGESTED_QUANTUM tasks per loop.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define DEFAULT_QUANTUM 50
|
||||||
|
#define CONGESTED_QUANTUM 5
|
||||||
|
#define CONGESTED_TASK_LIMIT 2
|
||||||
|
|
||||||
#define FINISHED(m) ((m)->exiting && EMPTY((m)->tasks))
|
#define FINISHED(m) ((m)->exiting && EMPTY((m)->tasks))
|
||||||
|
|
||||||
/*%
|
/*%
|
||||||
@@ -292,7 +301,7 @@ isc_task_create_bound(isc_taskmgr_t *manager0, unsigned int quantum,
|
|||||||
INIT_LIST(task->events);
|
INIT_LIST(task->events);
|
||||||
INIT_LIST(task->on_shutdown);
|
INIT_LIST(task->on_shutdown);
|
||||||
task->nevents = 0;
|
task->nevents = 0;
|
||||||
task->quantum = (quantum > 0) ? quantum : manager->default_quantum;
|
task->quantum = quantum;
|
||||||
task->flags = 0;
|
task->flags = 0;
|
||||||
task->now = 0;
|
task->now = 0;
|
||||||
isc_time_settoepoch(&task->tnow);
|
isc_time_settoepoch(&task->tnow);
|
||||||
@@ -932,6 +941,8 @@ pop_readyq(isc__taskmgr_t *manager, int c) {
|
|||||||
|
|
||||||
if (task != NULL) {
|
if (task != NULL) {
|
||||||
DEQUEUE(manager->queues[c].ready_tasks, task, ready_link);
|
DEQUEUE(manager->queues[c].ready_tasks, task, ready_link);
|
||||||
|
INSIST(manager->queues[c].tasks_waiting > 0);
|
||||||
|
manager->queues[c].tasks_waiting--;
|
||||||
if (ISC_LINK_LINKED(task, ready_priority_link)) {
|
if (ISC_LINK_LINKED(task, ready_priority_link)) {
|
||||||
DEQUEUE(manager->queues[c].ready_priority_tasks, task,
|
DEQUEUE(manager->queues[c].ready_priority_tasks, task,
|
||||||
ready_priority_link);
|
ready_priority_link);
|
||||||
@@ -950,12 +961,11 @@ pop_readyq(isc__taskmgr_t *manager, int c) {
|
|||||||
static inline void
|
static inline void
|
||||||
push_readyq(isc__taskmgr_t *manager, isc__task_t *task, int c) {
|
push_readyq(isc__taskmgr_t *manager, isc__task_t *task, int c) {
|
||||||
ENQUEUE(manager->queues[c].ready_tasks, task, ready_link);
|
ENQUEUE(manager->queues[c].ready_tasks, task, ready_link);
|
||||||
|
manager->queues[c].tasks_waiting++;
|
||||||
if ((task->flags & TASK_F_PRIVILEGED) != 0) {
|
if ((task->flags & TASK_F_PRIVILEGED) != 0) {
|
||||||
ENQUEUE(manager->queues[c].ready_priority_tasks, task,
|
ENQUEUE(manager->queues[c].ready_priority_tasks, task,
|
||||||
ready_priority_link);
|
ready_priority_link);
|
||||||
}
|
}
|
||||||
atomic_fetch_add_explicit(&manager->tasks_ready, 1,
|
|
||||||
memory_order_acquire);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -1095,6 +1105,16 @@ dispatch(isc__taskmgr_t *manager, unsigned int threadid) {
|
|||||||
task = pop_readyq(manager, threadid);
|
task = pop_readyq(manager, threadid);
|
||||||
if (task != NULL) {
|
if (task != NULL) {
|
||||||
unsigned int dispatch_count = 0;
|
unsigned int dispatch_count = 0;
|
||||||
|
unsigned int quantum = task->quantum;
|
||||||
|
if (quantum == 0) {
|
||||||
|
if (manager->queues[threadid].tasks_waiting
|
||||||
|
< CONGESTED_TASK_LIMIT)
|
||||||
|
{
|
||||||
|
quantum = DEFAULT_QUANTUM;
|
||||||
|
} else {
|
||||||
|
quantum = CONGESTED_QUANTUM;
|
||||||
|
}
|
||||||
|
}
|
||||||
bool done = false;
|
bool done = false;
|
||||||
bool requeue = false;
|
bool requeue = false;
|
||||||
bool finished = false;
|
bool finished = false;
|
||||||
@@ -1107,12 +1127,8 @@ dispatch(isc__taskmgr_t *manager, unsigned int threadid) {
|
|||||||
* have a task to do. We must reacquire the queue
|
* have a task to do. We must reacquire the queue
|
||||||
* lock before exiting the 'if (task != NULL)' block.
|
* lock before exiting the 'if (task != NULL)' block.
|
||||||
*/
|
*/
|
||||||
|
manager->queues[threadid].running = true;
|
||||||
UNLOCK(&manager->queues[threadid].lock);
|
UNLOCK(&manager->queues[threadid].lock);
|
||||||
RUNTIME_CHECK(
|
|
||||||
atomic_fetch_sub_explicit(&manager->tasks_ready,
|
|
||||||
1, memory_order_release) > 0);
|
|
||||||
atomic_fetch_add_explicit(&manager->tasks_running, 1,
|
|
||||||
memory_order_acquire);
|
|
||||||
|
|
||||||
LOCK(&task->lock);
|
LOCK(&task->lock);
|
||||||
INSIST(task->state == task_state_ready);
|
INSIST(task->state == task_state_ready);
|
||||||
@@ -1201,7 +1217,7 @@ dispatch(isc__taskmgr_t *manager, unsigned int threadid) {
|
|||||||
} else
|
} else
|
||||||
task->state = task_state_idle;
|
task->state = task_state_idle;
|
||||||
done = true;
|
done = true;
|
||||||
} else if (dispatch_count >= task->quantum) {
|
} else if (dispatch_count >= quantum) {
|
||||||
/*
|
/*
|
||||||
* Our quantum has expired, but
|
* Our quantum has expired, but
|
||||||
* there is more work to be done.
|
* there is more work to be done.
|
||||||
@@ -1226,10 +1242,8 @@ dispatch(isc__taskmgr_t *manager, unsigned int threadid) {
|
|||||||
if (finished)
|
if (finished)
|
||||||
task_finished(task);
|
task_finished(task);
|
||||||
|
|
||||||
RUNTIME_CHECK(
|
|
||||||
atomic_fetch_sub_explicit(&manager->tasks_running,
|
|
||||||
1, memory_order_release) > 0);
|
|
||||||
LOCK(&manager->queues[threadid].lock);
|
LOCK(&manager->queues[threadid].lock);
|
||||||
|
manager->queues[threadid].running = false;
|
||||||
if (requeue) {
|
if (requeue) {
|
||||||
/*
|
/*
|
||||||
* We know we're awake, so we don't have
|
* We know we're awake, so we don't have
|
||||||
@@ -1256,13 +1270,14 @@ dispatch(isc__taskmgr_t *manager, unsigned int threadid) {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* If we are in privileged execution mode and there are no
|
* If we are in privileged execution mode and there are no
|
||||||
* tasks remaining on the current ready queue, then
|
* tasks remaining on the current ready queue, we need to check
|
||||||
* we're stuck. Automatically drop privileges at that
|
* if maybe we need to drop from privileged to normal mode.
|
||||||
* point and continue with the regular ready queue.
|
* This might seem too heavy with all the locking but
|
||||||
|
* privileged mode is used only during startup and dropped
|
||||||
|
* once - after that this code is never executed.
|
||||||
*/
|
*/
|
||||||
if (manager->mode != isc_taskmgrmode_normal &&
|
if (manager->mode != isc_taskmgrmode_normal &&
|
||||||
atomic_load_explicit(&manager->tasks_running,
|
empty_readyq(manager, threadid))
|
||||||
memory_order_acquire) == 0)
|
|
||||||
{
|
{
|
||||||
UNLOCK(&manager->queues[threadid].lock);
|
UNLOCK(&manager->queues[threadid].lock);
|
||||||
LOCK(&manager->lock);
|
LOCK(&manager->lock);
|
||||||
@@ -1273,16 +1288,14 @@ dispatch(isc__taskmgr_t *manager, unsigned int threadid) {
|
|||||||
* we'll end up in a deadlock over queue locks.
|
* we'll end up in a deadlock over queue locks.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
if (manager->mode != isc_taskmgrmode_normal &&
|
if (manager->mode != isc_taskmgrmode_normal) {
|
||||||
atomic_load_explicit(&manager->tasks_running,
|
|
||||||
memory_order_acquire) == 0)
|
|
||||||
{
|
|
||||||
bool empty = true;
|
bool empty = true;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
for (i = 0; i < manager->workers && empty; i++)
|
for (i = 0; i < manager->workers && empty; i++)
|
||||||
{
|
{
|
||||||
LOCK(&manager->queues[i].lock);
|
LOCK(&manager->queues[i].lock);
|
||||||
empty &= empty_readyq(manager, i);
|
empty &= empty_readyq(manager, i) &&
|
||||||
|
!manager->queues[i].running;
|
||||||
UNLOCK(&manager->queues[i].lock);
|
UNLOCK(&manager->queues[i].lock);
|
||||||
}
|
}
|
||||||
if (empty) {
|
if (empty) {
|
||||||
@@ -1343,7 +1356,7 @@ manager_free(isc__taskmgr_t *manager) {
|
|||||||
|
|
||||||
isc_result_t
|
isc_result_t
|
||||||
isc_taskmgr_create(isc_mem_t *mctx, unsigned int workers,
|
isc_taskmgr_create(isc_mem_t *mctx, unsigned int workers,
|
||||||
unsigned int default_quantum, isc_taskmgr_t **managerp)
|
isc_taskmgr_t **managerp)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
isc__taskmgr_t *manager;
|
isc__taskmgr_t *manager;
|
||||||
@@ -1369,16 +1382,10 @@ isc_taskmgr_create(isc_mem_t *mctx, unsigned int workers,
|
|||||||
|
|
||||||
manager->workers = workers;
|
manager->workers = workers;
|
||||||
|
|
||||||
if (default_quantum == 0) {
|
|
||||||
default_quantum = DEFAULT_DEFAULT_QUANTUM;
|
|
||||||
}
|
|
||||||
manager->default_quantum = default_quantum;
|
|
||||||
INIT_LIST(manager->tasks);
|
INIT_LIST(manager->tasks);
|
||||||
manager->queues = isc_mem_get(mctx, workers * sizeof(isc__taskqueue_t));
|
manager->queues = isc_mem_get(mctx, workers * sizeof(isc__taskqueue_t));
|
||||||
RUNTIME_CHECK(manager->queues != NULL);
|
RUNTIME_CHECK(manager->queues != NULL);
|
||||||
|
|
||||||
manager->tasks_running = 0;
|
|
||||||
manager->tasks_ready = 0;
|
|
||||||
manager->curq = 0;
|
manager->curq = 0;
|
||||||
manager->exiting = false;
|
manager->exiting = false;
|
||||||
manager->excl = NULL;
|
manager->excl = NULL;
|
||||||
@@ -1400,6 +1407,8 @@ isc_taskmgr_create(isc_mem_t *mctx, unsigned int workers,
|
|||||||
|
|
||||||
manager->queues[i].manager = manager;
|
manager->queues[i].manager = manager;
|
||||||
manager->queues[i].threadid = i;
|
manager->queues[i].threadid = i;
|
||||||
|
manager->queues[i].tasks_waiting = 0;
|
||||||
|
manager->queues[i].running = false;
|
||||||
RUNTIME_CHECK(isc_thread_create(run, &manager->queues[i],
|
RUNTIME_CHECK(isc_thread_create(run, &manager->queues[i],
|
||||||
&manager->queues[i].thread)
|
&manager->queues[i].thread)
|
||||||
== ISC_R_SUCCESS);
|
== ISC_R_SUCCESS);
|
||||||
@@ -1708,21 +1717,6 @@ isc_taskmgr_renderxml(isc_taskmgr_t *mgr0, xmlTextWriterPtr writer) {
|
|||||||
TRY0(xmlTextWriterWriteFormatString(writer, "%d", mgr->workers));
|
TRY0(xmlTextWriterWriteFormatString(writer, "%d", mgr->workers));
|
||||||
TRY0(xmlTextWriterEndElement(writer)); /* worker-threads */
|
TRY0(xmlTextWriterEndElement(writer)); /* worker-threads */
|
||||||
|
|
||||||
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "default-quantum"));
|
|
||||||
TRY0(xmlTextWriterWriteFormatString(writer, "%d",
|
|
||||||
mgr->default_quantum));
|
|
||||||
TRY0(xmlTextWriterEndElement(writer)); /* default-quantum */
|
|
||||||
|
|
||||||
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "tasks-running"));
|
|
||||||
TRY0(xmlTextWriterWriteFormatString(writer, "%d",
|
|
||||||
(int) mgr->tasks_running));
|
|
||||||
TRY0(xmlTextWriterEndElement(writer)); /* tasks-running */
|
|
||||||
|
|
||||||
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "tasks-ready"));
|
|
||||||
TRY0(xmlTextWriterWriteFormatString(writer, "%d",
|
|
||||||
(int) mgr->tasks_ready));
|
|
||||||
TRY0(xmlTextWriterEndElement(writer)); /* tasks-ready */
|
|
||||||
|
|
||||||
TRY0(xmlTextWriterEndElement(writer)); /* thread-model */
|
TRY0(xmlTextWriterEndElement(writer)); /* thread-model */
|
||||||
|
|
||||||
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "tasks"));
|
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "tasks"));
|
||||||
@@ -1809,18 +1803,6 @@ isc_taskmgr_renderjson(isc_taskmgr_t *mgr0, json_object *tasks) {
|
|||||||
CHECKMEM(obj);
|
CHECKMEM(obj);
|
||||||
json_object_object_add(tasks, "worker-threads", obj);
|
json_object_object_add(tasks, "worker-threads", obj);
|
||||||
|
|
||||||
obj = json_object_new_int(mgr->default_quantum);
|
|
||||||
CHECKMEM(obj);
|
|
||||||
json_object_object_add(tasks, "default-quantum", obj);
|
|
||||||
|
|
||||||
obj = json_object_new_int(mgr->tasks_running);
|
|
||||||
CHECKMEM(obj);
|
|
||||||
json_object_object_add(tasks, "tasks-running", obj);
|
|
||||||
|
|
||||||
obj = json_object_new_int(mgr->tasks_ready);
|
|
||||||
CHECKMEM(obj);
|
|
||||||
json_object_object_add(tasks, "tasks-ready", obj);
|
|
||||||
|
|
||||||
array = json_object_new_array();
|
array = json_object_new_array();
|
||||||
CHECKMEM(array);
|
CHECKMEM(array);
|
||||||
|
|
||||||
@@ -1885,13 +1867,11 @@ isc_taskmgr_renderjson(isc_taskmgr_t *mgr0, json_object *tasks) {
|
|||||||
|
|
||||||
isc_result_t
|
isc_result_t
|
||||||
isc_taskmgr_createinctx(isc_mem_t *mctx, isc_appctx_t *actx,
|
isc_taskmgr_createinctx(isc_mem_t *mctx, isc_appctx_t *actx,
|
||||||
unsigned int workers, unsigned int default_quantum,
|
unsigned int workers, isc_taskmgr_t **managerp)
|
||||||
isc_taskmgr_t **managerp)
|
|
||||||
{
|
{
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
|
|
||||||
result = isc_taskmgr_create(mctx, workers, default_quantum,
|
result = isc_taskmgr_create(mctx, workers, managerp);
|
||||||
managerp);
|
|
||||||
|
|
||||||
if (result == ISC_R_SUCCESS)
|
if (result == ISC_R_SUCCESS)
|
||||||
isc_appctx_settaskmgr(actx, *managerp);
|
isc_appctx_settaskmgr(actx, *managerp);
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ create_managers(unsigned int workers) {
|
|||||||
workers = atoi(p);
|
workers = atoi(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECK(isc_taskmgr_create(mctx, workers, 0, &taskmgr));
|
CHECK(isc_taskmgr_create(mctx, workers, &taskmgr));
|
||||||
CHECK(isc_task_create(taskmgr, 0, &maintask));
|
CHECK(isc_task_create(taskmgr, 0, &maintask));
|
||||||
isc_taskmgr_setexcltask(taskmgr, maintask);
|
isc_taskmgr_setexcltask(taskmgr, maintask);
|
||||||
|
|
||||||
|
|||||||
@@ -712,7 +712,7 @@ manytasks(void **state) {
|
|||||||
result = isc_mem_create(0, 0, &mctx);
|
result = isc_mem_create(0, 0, &mctx);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
result = isc_taskmgr_create(mctx, 4, 0, &taskmgr);
|
result = isc_taskmgr_create(mctx, 4, &taskmgr);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
done = false;
|
done = false;
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ create_managers(void) {
|
|||||||
isc_event_t *event = NULL;
|
isc_event_t *event = NULL;
|
||||||
ncpus = isc_os_ncpus();
|
ncpus = isc_os_ncpus();
|
||||||
|
|
||||||
CHECK(isc_taskmgr_create(mctx, ncpus, 0, &taskmgr));
|
CHECK(isc_taskmgr_create(mctx, ncpus, &taskmgr));
|
||||||
CHECK(isc_task_create(taskmgr, 0, &maintask));
|
CHECK(isc_task_create(taskmgr, 0, &maintask));
|
||||||
isc_taskmgr_setexcltask(taskmgr, maintask);
|
isc_taskmgr_setexcltask(taskmgr, maintask);
|
||||||
CHECK(isc_task_onshutdown(maintask, shutdown_managers, NULL));
|
CHECK(isc_task_onshutdown(maintask, shutdown_managers, NULL));
|
||||||
|
|||||||
@@ -226,7 +226,7 @@ ctxs_init(isc_mem_t **mctxp, isc_appctx_t **actxp,
|
|||||||
if (result != ISC_R_SUCCESS)
|
if (result != ISC_R_SUCCESS)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
result = isc_taskmgr_createinctx(*mctxp, *actxp, 1, 0, taskmgrp);
|
result = isc_taskmgr_createinctx(*mctxp, *actxp, 1, taskmgrp);
|
||||||
if (result != ISC_R_SUCCESS)
|
if (result != ISC_R_SUCCESS)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
|
|||||||
@@ -381,7 +381,7 @@ main(int argc, char *argv[]) {
|
|||||||
result = isc_app_ctxstart(actx);
|
result = isc_app_ctxstart(actx);
|
||||||
if (result != ISC_R_SUCCESS)
|
if (result != ISC_R_SUCCESS)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
result = isc_taskmgr_createinctx(mctx, actx, 1, 0, &taskmgr);
|
result = isc_taskmgr_createinctx(mctx, actx, 1, &taskmgr);
|
||||||
if (result != ISC_R_SUCCESS)
|
if (result != ISC_R_SUCCESS)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
result = isc_socketmgr_createinctx(mctx, actx, &socketmgr);
|
result = isc_socketmgr_createinctx(mctx, actx, &socketmgr);
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ ctxs_init(isc_mem_t **mctxp, isc_appctx_t **actxp,
|
|||||||
if (result != ISC_R_SUCCESS)
|
if (result != ISC_R_SUCCESS)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
result = isc_taskmgr_createinctx(*mctxp, *actxp, 1, 0, taskmgrp);
|
result = isc_taskmgr_createinctx(*mctxp, *actxp, 1, taskmgrp);
|
||||||
if (result != ISC_R_SUCCESS)
|
if (result != ISC_R_SUCCESS)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user