From: Joshua C. Colp Date: Tue, 23 Sep 2025 22:54:35 +0000 (-0300) Subject: sorcery: Move from threadpool to taskpool. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=60c5010e38525dc24c4e87564544b022a67de9fa;p=thirdparty%2Fasterisk.git sorcery: Move from threadpool to taskpool. This change moves observer invocation from the use of a threadpool to a taskpool. The taskpool options have also been adjusted to ensure that at least one taskprocessor remains available at all times. --- diff --git a/main/sorcery.c b/main/sorcery.c index 0104437717..fba9173acd 100644 --- a/main/sorcery.c +++ b/main/sorcery.c @@ -39,7 +39,7 @@ #include "asterisk/netsock2.h" #include "asterisk/module.h" #include "asterisk/taskprocessor.h" -#include "asterisk/threadpool.h" +#include "asterisk/taskpool.h" #include "asterisk/json.h" #include "asterisk/vector.h" #include "asterisk/cli.h" @@ -83,8 +83,8 @@ #define NOTIFY_WIZARD_OBSERVERS(container, callback, ...) \ NOTIFY_GENERIC_OBSERVERS(container, sorcery_wizard_observer, callback, __VA_ARGS__) -/*! \brief Thread pool for observers */ -static struct ast_threadpool *threadpool; +/*! \brief Taskpool for observers */ +static struct ast_taskpool *taskpool; /*! \brief Structure for an internal wizard instance */ struct ast_sorcery_internal_wizard { @@ -402,8 +402,8 @@ static struct ast_cli_entry cli_commands[] = { static void sorcery_cleanup(void) { ast_cli_unregister_multiple(cli_commands, ARRAY_LEN(cli_commands)); - ast_threadpool_shutdown(threadpool); - threadpool = NULL; + ast_taskpool_shutdown(taskpool); + taskpool = NULL; ao2_cleanup(wizards); wizards = NULL; ao2_cleanup(observers); @@ -443,19 +443,20 @@ static void parse_general_options(void) int ast_sorcery_init(void) { - struct ast_threadpool_options options = { - .version = AST_THREADPOOL_OPTIONS_VERSION, + struct ast_taskpool_options options = { + .version = AST_TASKPOOL_OPTIONS_VERSION, .auto_increment = 1, .max_size = 0, .idle_timeout = 60, - .initial_size = 0, + .initial_size = 1, + .minimum_size = 1, }; ast_assert(wizards == NULL); parse_general_options(); - threadpool = ast_threadpool_create("sorcery", NULL, &options); - if (!threadpool) { + taskpool = ast_taskpool_create("sorcery", &options); + if (!taskpool) { return -1; } @@ -807,7 +808,7 @@ static struct ast_sorcery_object_type *sorcery_object_type_alloc(const char *typ /* Create name with seq number appended. */ ast_taskprocessor_build_name(tps_name, sizeof(tps_name), "sorcery/%s", type); - if (!(object_type->serializer = ast_threadpool_serializer(tps_name, threadpool))) { + if (!(object_type->serializer = ast_taskpool_serializer(tps_name, taskpool))) { ao2_ref(object_type, -1); return NULL; }