From: Arran Cudbard-Bell Date: Fri, 25 Apr 2025 00:09:11 +0000 (-0400) Subject: Just set fields in the worker config directly X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3711a74a8cc229449bc21e9e6762523c033f5839;p=thirdparty%2Ffreeradius-server.git Just set fields in the worker config directly --- diff --git a/src/bin/radiusd.c b/src/bin/radiusd.c index 846f1af0d9..f4b8538c7c 100644 --- a/src/bin/radiusd.c +++ b/src/bin/radiusd.c @@ -843,11 +843,8 @@ int main(int argc, char *argv[]) schedule->max_networks = config->max_networks; schedule->stats_interval = config->stats_interval; - schedule->network.max_outstanding = config->max_requests; - -#define COPY(_x) schedule->worker._x = config->_x - COPY(max_requests); - COPY(max_request_time); + schedule->network.max_outstanding = config->worker.max_requests; + schedule->worker = config->worker; /* * Single server mode: use the global event list. diff --git a/src/lib/server/client.c b/src/lib/server/client.c index bbf2a2e9b1..9658e3f51e 100644 --- a/src/lib/server/client.c +++ b/src/lib/server/client.c @@ -886,7 +886,7 @@ fr_client_t *client_afrom_cs(TALLOC_CTX *ctx, CONF_SECTION *cs, CONF_SECTION *se if (fr_time_delta_ispos(c->response_window)) { FR_TIME_DELTA_BOUND_CHECK("response_window", c->response_window, >=, fr_time_delta_from_usec(1000)); FR_TIME_DELTA_BOUND_CHECK("response_window", c->response_window, <=, fr_time_delta_from_sec(60)); - FR_TIME_DELTA_BOUND_CHECK("response_window", c->response_window, <=, main_config->max_request_time); + FR_TIME_DELTA_BOUND_CHECK("response_window", c->response_window, <=, main_config->worker.max_request_time); } #ifdef WITH_TLS diff --git a/src/lib/server/main_config.c b/src/lib/server/main_config.c index 6194b1b40f..5d0d6431e5 100644 --- a/src/lib/server/main_config.c +++ b/src/lib/server/main_config.c @@ -152,7 +152,7 @@ static const conf_parser_t resources[] = { * the config item will *not* get printed out in debug mode, so that no one knows * it exists. */ - { FR_CONF_OFFSET_TYPE_FLAGS("talloc_pool_size", FR_TYPE_SIZE, CONF_FLAG_HIDDEN, main_config_t, talloc_pool_size), .func = talloc_pool_size_parse }, /* DO NOT SET DEFAULT */ + { FR_CONF_OFFSET_TYPE_FLAGS("talloc_pool_size", FR_TYPE_SIZE, CONF_FLAG_HIDDEN, main_config_t, worker.talloc_pool_size), .func = talloc_pool_size_parse }, /* DO NOT SET DEFAULT */ { FR_CONF_OFFSET_FLAGS("talloc_memory_report", CONF_FLAG_HIDDEN, main_config_t, talloc_memory_report) }, /* DO NOT SET DEFAULT */ CONF_PARSER_TERMINATOR }; @@ -211,11 +211,11 @@ static const conf_parser_t server_config[] = { { FR_CONF_OFFSET("panic_action", main_config_t, panic_action) }, { FR_CONF_OFFSET("reverse_lookups", main_config_t, reverse_lookups), .dflt = "no", .func = reverse_lookups_parse }, { FR_CONF_OFFSET("hostname_lookups", main_config_t, hostname_lookups), .dflt = "yes", .func = hostname_lookups_parse }, - { FR_CONF_OFFSET("max_request_time", main_config_t, max_request_time), .dflt = STRINGIFY(MAX_REQUEST_TIME), .func = max_request_time_parse }, + { FR_CONF_OFFSET("max_request_time", main_config_t, worker.max_request_time), .dflt = STRINGIFY(MAX_REQUEST_TIME), .func = max_request_time_parse }, { FR_CONF_OFFSET("pidfile", main_config_t, pid_file), .dflt = "${run_dir}/radiusd.pid"}, { FR_CONF_OFFSET_FLAGS("debug_level", CONF_FLAG_HIDDEN, main_config_t, debug_level), .dflt = "0" }, - { FR_CONF_OFFSET("max_requests", main_config_t, max_requests), .dflt = "0" }, + { FR_CONF_OFFSET("max_requests", main_config_t, worker.max_requests), .dflt = "0" }, { FR_CONF_POINTER("log", 0, CONF_FLAG_SUBSECTION, NULL), .subcs = (void const *) log_config }, @@ -1061,7 +1061,7 @@ int main_config_init(main_config_t *config) * * Which should be enough for many configurations. */ - config->talloc_pool_size = 8 * 1024; /* default */ + config->worker.talloc_pool_size = 8 * 1024; /* default */ cs = cf_section_alloc(NULL, NULL, "main", NULL); if (!cs) return -1; diff --git a/src/lib/server/main_config.h b/src/lib/server/main_config.h index 365c7951fa..5a8b30b0d5 100644 --- a/src/lib/server/main_config.h +++ b/src/lib/server/main_config.h @@ -42,7 +42,7 @@ extern main_config_t const *main_config; //!< Global configuration singleton. #include #include - +#include /** Main server configuration * @@ -58,8 +58,7 @@ struct main_config_s { bool spawn_workers; //!< Should the server spawn threads. char const *pid_file; //!< Path to write out PID file. - fr_time_delta_t max_request_time; //!< How long a request can be processed for before - //!< timing out. + fr_worker_config_t worker; //!< Worker thread configuration. bool drop_requests; //!< Administratively disable request processing. bool suppress_secrets; //!< suppress secrets (or not) @@ -93,10 +92,6 @@ struct main_config_s { char const *dict_dir; //!< Where to load dictionaries from. - size_t talloc_pool_size; //!< Size of pool to allocate to hold each #request_t. - - uint32_t max_requests; //!< maximum number of requests outstanding - bool write_pid; //!< write the PID file #ifdef HAVE_SETUID