Load plugins only once, even if listed twice

This commit is contained in:
Martin Willi
2011-01-05 16:45:49 +01:00
parent 9a99b745c0
commit 1535913aed
+27
View File
@@ -156,6 +156,28 @@ static plugin_t* load_plugin(private_plugin_loader_t *this,
}
#endif
/**
* Check if a plugin is already loaded
*/
static bool plugin_loaded(private_plugin_loader_t *this, char *name)
{
enumerator_t *enumerator;
bool found = FALSE;
char *current;
enumerator = this->names->create_enumerator(this->names);
while (enumerator->enumerate(enumerator, &current))
{
if (streq(name, current))
{
found = TRUE;
break;
}
}
enumerator->destroy(enumerator);
return found;
}
/**
* Implementation of plugin_loader_t.load_plugins.
*/
@@ -186,6 +208,11 @@ static bool load(private_plugin_loader_t *this, char *path, char *list)
critical = TRUE;
token[len-1] = '\0';
}
if (plugin_loaded(this, token))
{
free(token);
continue;
}
plugin = load_plugin(this, path, token);
if (plugin)
{