Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Clean up code for conditionally loading a module
  • Loading branch information
alandekok committed Apr 14, 2013
1 parent a5c67e6 commit 81838dc
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/main/modcall.c
Expand Up @@ -2000,15 +2000,25 @@ static modcallable *do_compile_modsingle(modcallable *parent,
const char *realname = modrefname;
if (realname[0] == '-') realname++;

this = find_module_instance(modules, realname, 1);
if (!this && (realname != modrefname)) {
/*
* As of v3, only known modules are in the
* "modules" section.
*/
if (!cf_section_sub_find_name2(modules, NULL, realname)) {
/*
* We tried to load the module, but it doesn't exist.
* Give a silent error.
*/
*modname = modrefname;
return NULL;
}

/*
* It's "-foo" and it has a module config, but we
* can't load it. That's a hard error.
*/
this = find_module_instance(modules, realname, 1);
if (!this && (realname != modrefname)) return NULL;
}

if (!this) do {
Expand Down

0 comments on commit 81838dc

Please sign in to comment.