Skip to content

Commit

Permalink
Fix module API and use consistent names
Browse files Browse the repository at this point in the history
  • Loading branch information
alandekok committed Apr 8, 2014
1 parent bf8b856 commit 9460045
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 32 deletions.
6 changes: 3 additions & 3 deletions src/include/modules.h
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/main/mainconfig.c
Expand Up @@ -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.
Expand Down
38 changes: 14 additions & 24 deletions src/main/modules.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions src/main/radiusd.c
Expand Up @@ -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);
}

Expand Down Expand Up @@ -598,7 +598,7 @@ int main(int argc, char *argv[])
/*
* Detach any modules.
*/
detach_modules();
modules_free();

xlat_free(); /* modules may have xlat's */

Expand Down
4 changes: 2 additions & 2 deletions src/main/unittest.c
Expand Up @@ -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);
}

Expand Down Expand Up @@ -652,7 +652,7 @@ int main(int argc, char *argv[])
/*
* Detach any modules.
*/
detach_modules();
modules_free();

xlat_free(); /* modules may have xlat's */

Expand Down

0 comments on commit 9460045

Please sign in to comment.