diff options
author | Martin Willi <martin@revosec.ch> | 2010-11-23 11:06:46 +0100 |
---|---|---|
committer | Martin Willi <martin@revosec.ch> | 2011-01-05 16:45:49 +0100 |
commit | 1535913aedd2a34002d385083d78822c598ea5b3 (patch) | |
tree | 242292621b62dc9ebedab5e5fb2514de50481399 /src | |
parent | 9a99b745c02f629b2e7fdf22be40e24a2e2d2569 (diff) | |
download | strongswan-1535913aedd2a34002d385083d78822c598ea5b3.tar.bz2 strongswan-1535913aedd2a34002d385083d78822c598ea5b3.tar.xz |
Load plugins only once, even if listed twice
Diffstat (limited to 'src')
-rw-r--r-- | src/libstrongswan/plugins/plugin_loader.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/libstrongswan/plugins/plugin_loader.c b/src/libstrongswan/plugins/plugin_loader.c index e1427bf15..67aa178b6 100644 --- a/src/libstrongswan/plugins/plugin_loader.c +++ b/src/libstrongswan/plugins/plugin_loader.c @@ -157,6 +157,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, ¤t)) + { + if (streq(name, current)) + { + found = TRUE; + break; + } + } + enumerator->destroy(enumerator); + return found; +} + +/** * Implementation of plugin_loader_t.load_plugins. */ static bool load(private_plugin_loader_t *this, char *path, char *list) @@ -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) { |