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
/** 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
* - 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)
{
return NULL;
}
+ sc->el = el;
sc->max_inputs = max_inputs;
sc->max_workers = max_workers;
sc->num_workers = 0;
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);
* 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);
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);
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);