]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
add event_list_t to scheduler
authorAlan T. DeKok <aland@freeradius.org>
Tue, 20 Jun 2017 17:05:56 +0000 (13:05 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 20 Jun 2017 17:31:59 +0000 (13:31 -0400)
in preparation for single-threaded mode

src/lib/io/schedule.c
src/lib/io/schedule.h
src/main/radiusd.c
src/tests/util/radius_schedule_test.c
src/tests/util/schedule_test.c

index 448ef29ad97a90aebb2bb602438f52f604505a2b..5731dcfc635e4f292e3838d142424e06ec94c21a 100644 (file)
@@ -110,6 +110,8 @@ typedef struct fr_schedule_network_t {
 struct fr_schedule_t {
        bool            running;                //!< is the scheduler running?
 
+       fr_event_list_t *el;                    //!< event list for single-threaded mode.
+
        fr_log_t        *log;                   //!< log destination
 
        int             max_inputs;             //!< number of network threads
@@ -295,6 +297,7 @@ fail:
 /** Create a scheduler and spawn the child threads.
  *
  * @param[in] ctx the talloc context
+ * @param[in] el the event list, only for single-threaded mode.
  * @param[in] logger the destination for all logging messages
  * @param[in] max_inputs the number of network threads
  * @param[in] max_workers the number of worker threads
@@ -304,7 +307,8 @@ fail:
  *     - NULL on error
  *     - fr_schedule_t new scheduler
  */
-fr_schedule_t *fr_schedule_create(TALLOC_CTX *ctx, fr_log_t *logger, int max_inputs, int max_workers,
+fr_schedule_t *fr_schedule_create(TALLOC_CTX *ctx, fr_event_list_t *el, fr_log_t *logger,
+                                 int max_inputs, int max_workers,
                                  fr_schedule_thread_instantiate_t worker_thread_instantiate,
                                  void *worker_thread_ctx)
 {
@@ -327,6 +331,7 @@ fr_schedule_t *fr_schedule_create(TALLOC_CTX *ctx, fr_log_t *logger, int max_inp
                return NULL;
        }
 
+       sc->el = el;
        sc->max_inputs = max_inputs;
        sc->max_workers = max_workers;
        sc->num_workers = 0;
index e818936d3687c645479e577abe9993f20c6f7369..62f353692ab645aa7e98815e091271b7918ab5e0 100644 (file)
@@ -36,9 +36,9 @@ extern "C" {
 typedef struct fr_schedule_t fr_schedule_t;
 typedef int (*fr_schedule_thread_instantiate_t)(void *ctx, fr_event_list_t *el);
 
-fr_schedule_t          *fr_schedule_create(TALLOC_CTX *ctx, fr_log_t *log, int max_inputs, int max_workers,
+fr_schedule_t          *fr_schedule_create(TALLOC_CTX *ctx, fr_event_list_t *el, fr_log_t *log, int max_inputs, int max_workers,
                                            fr_schedule_thread_instantiate_t worker_thread_instantiate,
-                                           void *worker_thread_ctx);
+                                           void *worker_thread_ctx) CC_HINT(nonnull(3));
 /* schedulers are async, so there's no fr_schedule_run() */
 int                    fr_schedule_destroy(fr_schedule_t *sc);
 
index b0b82292bd8a3e31c0ad471ced64d16798f980de..a46bcd2c08bb18a5fa51ec6beb39598a4cc95a45 100644 (file)
@@ -585,7 +585,21 @@ int main(int argc, char *argv[])
         *      async listeners, then we open the sockets.
         */
        if (!check_config && main_config.namespace) {
-               sc = fr_schedule_create(NULL, &default_log, 1, 4, (fr_schedule_thread_instantiate_t) modules_thread_instantiate,
+               int networks = 1;
+               int workers = 4;
+               fr_event_list_t *el = NULL;
+
+               if (!main_config.spawn_workers) {
+                       networks = 0;
+                       workers = 0;
+                       el = process_global_event_list(EVENT_CORRAL_MAIN);
+               }
+
+               /*
+                *      @todo - fix this once the scheduler supports single-threaded mode
+                */
+               sc = fr_schedule_create(NULL, NULL, &default_log, 1, 4,
+                                       (fr_schedule_thread_instantiate_t) modules_thread_instantiate,
                                        main_config.config);
                if (!sc) {
                        exit(EXIT_FAILURE);
index bf9625ac48e63034e38d770bb6a6b64e557c9008..c40455ee11ec72e4e32a86d66da112564038c0f9 100644 (file)
@@ -269,7 +269,7 @@ int main(int argc, char *argv[])
        app_io_inst->ipaddr = my_ipaddr;
        app_io_inst->port = my_port;
 
-       sched = fr_schedule_create(autofree, &default_log, num_networks, num_workers, NULL, NULL);
+       sched = fr_schedule_create(autofree, NULL, &default_log, num_networks, num_workers, NULL, NULL);
        if (!sched) {
                fprintf(stderr, "schedule_test: Failed to create scheduler\n");
                exit(1);
index 33590096242cc18848f08253f137b48879ce1de1..5447ee7fbdafc9336ccd88bde43f17b28c897194 100644 (file)
@@ -91,7 +91,7 @@ int main(int argc, char *argv[])
        argv += (optind - 1);
 #endif
 
-       sched = fr_schedule_create(autofree, &default_log, num_networks, num_workers, NULL, NULL);
+       sched = fr_schedule_create(autofree, NULL, &default_log, num_networks, num_workers, NULL, NULL);
        if (!sched) {
                fprintf(stderr, "schedule_test: Failed to create scheduler\n");
                exit(1);