aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstrongswan/plugins/plugin_loader.c
diff options
context:
space:
mode:
authorTobias Brunner <tobias@strongswan.org>2011-09-22 18:04:53 +0200
committerMartin Willi <martin@revosec.ch>2011-10-14 10:05:46 +0200
commitef80de60109335a5e535fc1bf38bc4e25ad8268f (patch)
treede650c7fde0ef4851abd6069ec15c6deb06208e4 /src/libstrongswan/plugins/plugin_loader.c
parent40e856fada234aa6acc29b95824729e45d085c40 (diff)
downloadstrongswan-ef80de60109335a5e535fc1bf38bc4e25ad8268f.tar.bz2
strongswan-ef80de60109335a5e535fc1bf38bc4e25ad8268f.tar.xz
Unload plugins which we were not able to load any features from.
Diffstat (limited to 'src/libstrongswan/plugins/plugin_loader.c')
-rw-r--r--src/libstrongswan/plugins/plugin_loader.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/libstrongswan/plugins/plugin_loader.c b/src/libstrongswan/plugins/plugin_loader.c
index 462ba7047..8e34ca527 100644
--- a/src/libstrongswan/plugins/plugin_loader.c
+++ b/src/libstrongswan/plugins/plugin_loader.c
@@ -441,6 +441,30 @@ static int load_features(private_plugin_loader_t *this, bool soft, bool report)
return loaded;
}
+/**
+ * Remove plugins that we were not able to load any features from.
+ */
+static void purge_plugins(private_plugin_loader_t *this)
+{
+ enumerator_t *enumerator;
+ plugin_entry_t *entry;
+
+ enumerator = this->plugins->create_enumerator(this->plugins);
+ while (enumerator->enumerate(enumerator, &entry))
+ {
+ if (!entry->plugin->get_features)
+ { /* feature interface not supported */
+ continue;
+ }
+ if (!entry->loaded->get_count(entry->loaded))
+ {
+ this->plugins->remove_at(this->plugins, enumerator);
+ plugin_entry_destroy(entry);
+ }
+ }
+ enumerator->destroy(enumerator);
+}
+
METHOD(plugin_loader_t, load_plugins, bool,
private_plugin_loader_t *this, char *path, char *list)
{
@@ -497,6 +521,8 @@ METHOD(plugin_loader_t, load_plugins, bool,
}
/* report missing dependencies */
load_features(this, FALSE, TRUE);
+ /* unload plugins that we were not able to load any features for */
+ purge_plugins(this);
}
return !critical_failed;
}