Skip to content

Commit 51a9010

Browse files
committed
Allow modules to use the main event loop for low frequency I/O and timer events
Saves spawning dedicated threads... we may want to revisit this in future
1 parent 1ae93d6 commit 51a9010

1 file changed

Lines changed: 17 additions & 12 deletions

File tree

src/bin/radiusd.c

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,23 @@ do { \
810810
*/
811811
if (unlang_global_init() < 0) EXIT_WITH_FAILURE;
812812

813+
/*
814+
* Initialize the global event loop which handles things like
815+
* systemd.
816+
*
817+
* This has to be done post-fork in case we're using kqueue, where the
818+
* queue isn't inherited by the child process.
819+
*
820+
* Done before `server_init` so that module instantiate callbacks can
821+
* register fds / timers against `main_loop_event_list()` directly.
822+
* `main_loop_init` has no dependencies on module or virtual server
823+
* state, so this reordering is safe.
824+
*/
825+
if (main_loop_init() < 0) {
826+
PERROR("Failed initialising main event loop");
827+
EXIT_WITH_FAILURE;
828+
}
829+
813830
if (server_init(config->root_cs, config->confdir, fr_dict_unconst(fr_dict_internal())) < 0) EXIT_WITH_FAILURE;
814831

815832
/*
@@ -828,18 +845,6 @@ do { \
828845
EXIT_WITH_FAILURE;
829846
}
830847

831-
/*
832-
* Initialize the global event loop which handles things like
833-
* systemd.
834-
*
835-
* This has to be done post-fork in case we're using kqueue, where the
836-
* queue isn't inherited by the child process.
837-
*/
838-
if (main_loop_init() < 0) {
839-
PERROR("Failed initialising main event loop");
840-
EXIT_WITH_FAILURE;
841-
}
842-
843848
/*
844849
* Start the network / worker threads.
845850
*/

0 commit comments

Comments
 (0)