Fix module API and use consistent names
authorAlan T. DeKok <aland@freeradius.org>
Tue, 8 Apr 2014 15:15:26 +0000 (11:15 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 8 Apr 2014 15:15:26 +0000 (11:15 -0400)
src/include/modules.h
src/main/mainconfig.c
src/main/modules.c
src/main/radiusd.c
src/main/unittest.c

index e3a0c50..64f0e27 100644 (file)
@@ -166,9 +166,9 @@ typedef struct module_t {
 
 } module_t;
 
-int setup_modules(int, CONF_SECTION *);
-int detach_modules(void);
-int module_hup(CONF_SECTION *modules);
+int modules_init(CONF_SECTION *);
+int modules_free(void);
+int modules_hup(CONF_SECTION *modules);
 rlm_rcode_t process_authorize(int type, REQUEST *request);
 rlm_rcode_t process_authenticate(int type, REQUEST *request);
 rlm_rcode_t module_preacct(REQUEST *request);
index e415bc1..a615947 100644 (file)
@@ -1079,7 +1079,7 @@ void hup_mainconfig(void)
        /*
         *      Prefer the new module configuration.
         */
-       module_hup(cf_section_sub_find(cs, "modules"));
+       modules_hup(cf_section_sub_find(cs, "modules"));
 
        /*
         *      Load new servers BEFORE freeing old ones.
index e5c5730..0156f10 100644 (file)
@@ -402,7 +402,7 @@ static int module_entry_free(module_entry_t *this)
 /*
  *     Remove the module lists.
  */
-int detach_modules(void)
+int modules_free(void)
 {
        rbtree_free(instance_tree);
        rbtree_free(module_tree);
@@ -1437,7 +1437,7 @@ int module_hup_module(CONF_SECTION *cs, module_instance_t *node, time_t when)
 }
 
 
-int module_hup(CONF_SECTION *modules)
+int modules_hup(CONF_SECTION *modules)
 {
        time_t when;
        CONF_ITEM *ci;
@@ -1479,37 +1479,27 @@ int module_hup(CONF_SECTION *modules)
 /*
  *     Parse the module config sections, and load
  *     and call each module's init() function.
- *
- *     Libtool makes your life a LOT easier, especially with libltdl.
- *     see: http://www.gnu.org/software/libtool/
  */
-int setup_modules(int reload, CONF_SECTION *config)
+int modules_init(CONF_SECTION *config)
 {
        CONF_ITEM       *ci, *next;
        CONF_SECTION    *cs, *modules;
        rad_listen_t    *listener;
 
-       if (reload) return 0;
-
        /*
-        *      If necessary, initialize libltdl.
+        *      Set up the internal module struct.
         */
-       if (!reload) {
-               /*
-                *      Set up the internal module struct.
-                */
-               module_tree = rbtree_create(module_entry_cmp, NULL, 0);
-               if (!module_tree) {
-                       ERROR("Failed to initialize modules\n");
-                       return -1;
-               }
+       module_tree = rbtree_create(module_entry_cmp, NULL, 0);
+       if (!module_tree) {
+               ERROR("Failed to initialize modules\n");
+               return -1;
+       }
 
-               instance_tree = rbtree_create(module_instance_cmp,
-                                             module_instance_free, 0);
-               if (!instance_tree) {
-                       ERROR("Failed to initialize modules\n");
-                       return -1;
-               }
+       instance_tree = rbtree_create(module_instance_cmp,
+                                     module_instance_free, 0);
+       if (!instance_tree) {
+               ERROR("Failed to initialize modules\n");
+               return -1;
        }
 
        memset(virtual_servers, 0, sizeof(virtual_servers));
index 251cf34..d755918 100644 (file)
@@ -345,7 +345,7 @@ int main(int argc, char *argv[])
        /*
         *  Load the modules
         */
-       if (setup_modules(false, mainconfig.config) < 0) {
+       if (modules_init(mainconfig.config) < 0) {
                exit(EXIT_FAILURE);
        }
 
@@ -598,7 +598,7 @@ cleanup:
        /*
         *      Detach any modules.
         */
-       detach_modules();
+       modules_free();
 
        xlat_free();            /* modules may have xlat's */
 
index 6e79e6c..dd051d4 100644 (file)
@@ -538,7 +538,7 @@ int main(int argc, char *argv[])
        /*
         *  Load the modules
         */
-       if (setup_modules(false, mainconfig.config) < 0) {
+       if (modules_init(mainconfig.config) < 0) {
                exit(EXIT_FAILURE);
        }
 
@@ -652,7 +652,7 @@ int main(int argc, char *argv[])
        /*
         *      Detach any modules.
         */
-       detach_modules();
+       modules_free();
 
        xlat_free();            /* modules may have xlat's */