]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Just set fields in the worker config directly
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 25 Apr 2025 00:09:11 +0000 (20:09 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 25 Apr 2025 15:34:02 +0000 (11:34 -0400)
src/bin/radiusd.c
src/lib/server/client.c
src/lib/server/main_config.c
src/lib/server/main_config.h

index 846f1af0d96d2cb095cc4682709899d58bff0d86..f4b8538c7c579bf72e7a8e4a5a7c7ee905de82f0 100644 (file)
@@ -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.
index bbf2a2e9b135ae95d51b3f223b61a1c2114dd198..9658e3f51ebb5764ec5888e31b31ad21e627bc0a 100644 (file)
@@ -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
index 6194b1b40ffe600fb52a14c0ed7fd1937f09a6c2..5d0d6431e5b6b80d9de63792496eecbffa825ac1 100644 (file)
@@ -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;
index 365c7951fa8a822ab167f616f0009cf1e7cb55a3..5a8b30b0d5ed27a82dc52f6405527062dea6d430 100644 (file)
@@ -42,7 +42,7 @@ extern main_config_t const *main_config;              //!< Global configuration singleton.
 #include <freeradius-devel/server/tmpl.h>
 
 #include <freeradius-devel/util/dict.h>
-
+#include <freeradius-devel/io/worker.h>
 
 /** 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