aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstrongswan/plugins/plugin_loader.c
diff options
context:
space:
mode:
authorMartin Willi <martin@revosec.ch>2011-10-13 17:27:02 +0200
committerMartin Willi <martin@revosec.ch>2011-10-14 10:05:49 +0200
commita07f2a4b9b8ca1a7f6d73f2305e69445bb54dc99 (patch)
tree520e224a25d90a899882fa4734541c4921c7241d /src/libstrongswan/plugins/plugin_loader.c
parent9894b91ca9bf47b4d282dcc00f7c9c35d26a6e4e (diff)
downloadstrongswan-a07f2a4b9b8ca1a7f6d73f2305e69445bb54dc99.tar.bz2
strongswan-a07f2a4b9b8ca1a7f6d73f2305e69445bb54dc99.tar.xz
Don't try to load a feature again after failure
Diffstat (limited to 'src/libstrongswan/plugins/plugin_loader.c')
-rw-r--r--src/libstrongswan/plugins/plugin_loader.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/src/libstrongswan/plugins/plugin_loader.c b/src/libstrongswan/plugins/plugin_loader.c
index b97a5f3e6..006a1b750 100644
--- a/src/libstrongswan/plugins/plugin_loader.c
+++ b/src/libstrongswan/plugins/plugin_loader.c
@@ -66,6 +66,11 @@ struct plugin_entry_t {
* List of loaded features
*/
linked_list_t *loaded;
+
+ /**
+ * List features failed to load
+ */
+ linked_list_t *failed;
};
/**
@@ -79,6 +84,7 @@ static void plugin_entry_destroy(plugin_entry_t *entry)
dlclose(entry->handle);
}
entry->loaded->destroy(entry->loaded);
+ entry->failed->destroy(entry->failed);
free(entry);
}
@@ -125,6 +131,7 @@ static status_t create_plugin(private_plugin_loader_t *this, void *handle,
INIT(*entry,
.plugin = plugin,
.loaded = linked_list_create(),
+ .failed = linked_list_create(),
);
DBG2(DBG_LIB, "plugin '%s': loaded successfully", name);
return SUCCESS;
@@ -229,6 +236,16 @@ static bool feature_loaded(private_plugin_loader_t *this, plugin_entry_t *entry,
}
/**
+ * Check if loading a feature of a plugin failed
+ */
+static bool feature_failed(private_plugin_loader_t *this, plugin_entry_t *entry,
+ plugin_feature_t *feature)
+{
+ return entry->failed->find_first(entry->failed, NULL,
+ (void**)&feature) == SUCCESS;
+}
+
+/**
* Check if dependencies are satisfied
*/
static bool dependencies_satisfied(private_plugin_loader_t *this,
@@ -350,12 +367,19 @@ static int load_features(private_plugin_loader_t *this, bool soft, bool report)
{
case FEATURE_PROVIDE:
if (!feature_loaded(this, entry, feature) &&
+ !feature_failed(this, entry, feature) &&
dependencies_satisfied(this, entry, soft, report,
- feature, count - i) &&
- plugin_feature_load(entry->plugin, feature, reg))
+ feature, count - i))
{
- entry->loaded->insert_last(entry->loaded, feature);
- loaded++;
+ if (plugin_feature_load(entry->plugin, feature, reg))
+ {
+ entry->loaded->insert_last(entry->loaded, feature);
+ loaded++;
+ }
+ else
+ {
+ entry->failed->insert_last(entry->failed, feature);
+ }
}
break;
case FEATURE_REGISTER: