]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Move global_lib_init and instantiation calls inside the module code
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 2 Jun 2022 17:10:31 +0000 (13:10 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 2 Jun 2022 17:10:31 +0000 (13:10 -0400)
src/bin/radiusd.c
src/lib/server/global_lib.c
src/lib/server/module.c
src/lib/server/module_rlm.c
src/lib/server/virtual_servers.c

index 97712cadfc1d09ebbb183be954e744aa76a81efc..a9e502a2d57f789d1982be175276b87404a9fe40 100644 (file)
@@ -573,21 +573,11 @@ int main(int argc, char *argv[])
                EXIT_WITH_FAILURE;
        }
 
-       /*
-        *      Setup the global structure for libraries
-        */
-       if (global_lib_init() < 0) EXIT_WITH_FAILURE;
-
        /*
         *  Read the configuration files, BEFORE doing anything else.
         */
        if (main_config_init(config) < 0) EXIT_WITH_FAILURE;
 
-       /*
-        *      Instantiate any libraries loaded by config parsing
-        */
-       if (global_lib_instantiate() < 0) EXIT_WITH_FAILURE;
-
        /*
         *  Check we're the only process using this config.
         */
index a4d11eb2516c91145ac87a559154d23747fc8153..8cc37a3e4da121d11fcc0c5a620d202c35671be2 100644 (file)
@@ -203,6 +203,8 @@ static int _lib_list_free_atexit(UNUSED void *uctx)
  */
 int global_lib_init(void)
 {
+       if (lib_list) return;
+
        MEM(lib_list = talloc_zero(NULL, global_lib_list_t));
        fr_rb_inline_init(&lib_list->libs, global_lib_inst_t, entry, _lib_cmp, NULL);
 
index c598f08108091e80224d9a693510a7c12c3d4ea4..ee7e09e5b08d9a48fe1bf531d695331dd2c13d73 100644 (file)
@@ -1106,10 +1106,17 @@ static void _module_global_list_init(void *uctx)
 {
        dl_modules = dl_module_loader_init(uctx);
        MEM(module_global_inst_list = fr_heap_alloc(NULL, _module_instance_global_cmp, module_instance_t, inst_idx, 256));
+
+       /*
+        *      Ensure the common library tracking
+        *      tree is in place...
+        */
+       global_lib_init();
 }
 
 static int _module_global_list_free(UNUSED void *uctx)
 {
+
        if (!fr_cond_assert_msg(fr_heap_num_elements(module_global_inst_list) == 0,
                                "Global module heap has %u elements remaining on exit.  This is a leak",
                                fr_heap_num_elements(module_global_inst_list))) return -1;
index a9e01f6a35f03b101f0eff55e79a3e5ca972f6bb..158325ecee2aac791bfef831ef0e08eb409fff11 100644 (file)
@@ -1005,6 +1005,12 @@ int modules_rlm_bootstrap(CONF_SECTION *root)
        module_rlm_virtual_t    *vm;
        fr_rb_iter_inorder_t    iter;
        CONF_SECTION            *actions;
+
+       /*
+        *      Ensure any libraries the modules depend on are instantiated
+        */
+       global_lib_instantiate();
+
        /*
         *      Remember where the modules were stored.
         */
index d748bd83e5934604acf489b699f8974d373c3014..54e9f42672e4eb9a7c9ba01ed4336918a26123d4 100644 (file)
@@ -1277,6 +1277,11 @@ int virtual_servers_bootstrap(CONF_SECTION *config)
 {
        virtual_server_root = config;
 
+       /*
+        *      Ensure any libraries the modules depend on are instantiated
+        */
+       global_lib_instantiate();
+
        if (modules_bootstrap(process_modules) < 0) return -1;
        if (modules_bootstrap(proto_modules) < 0) return -1;