*/
bool critical;
+#ifdef HAVE_DLADDR
/**
* dlopen handle, if in separate lib
*/
void *handle;
+#endif
/**
* List of features, as provided_feature_t
static void plugin_entry_destroy(plugin_entry_t *entry)
{
DESTROY_IF(entry->plugin);
+#ifdef HAVE_DLADDR
if (entry->handle)
{
dlclose(entry->handle);
}
+#endif
entry->features->destroy(entry->features);
free(entry);
}
{
constructor = plugin_constructors->get(plugin_constructors, name);
}
+#elif defined(HAVE_DLADDR)
if (!constructor)
-#endif
{
constructor = dlsym(handle, create);
}
+#else
+ #error Neither dynamic linking nor static plugin constructors are supported!
+#endif
if (!constructor)
{
return NOT_FOUND;
{
char create[128];
plugin_entry_t *entry;
- void *handle;
+ void *handle = NULL;
+
+#ifdef HAVE_DLADDR
int flag = RTLD_LAZY;
+ handle = RTLD_DEFAULT;
+#endif
if (snprintf(create, sizeof(create), "%s_plugin_create",
name) >= sizeof(create))
return NULL;
}
translate(create, "-", "_");
- switch (create_plugin(this, RTLD_DEFAULT, name, create, FALSE, critical,
+ switch (create_plugin(this, handle, name, create, FALSE, critical,
&entry))
{
case SUCCESS:
return NULL;
}
}
+#ifdef HAVE_DLADDR
if (lib->settings->get_bool(lib->settings, "%s.dlopen_use_rtld_now",
FALSE, lib->ns))
{
entry->handle = handle;
this->plugins->insert_last(this->plugins, entry);
return entry;
+#else
+ return NULL;
+#endif
}
CALLBACK(feature_filter, bool,
unload_features(this);
while (this->plugins->remove_last(this->plugins, (void**)&entry) == SUCCESS)
{
+#ifdef HAVE_DLADDR
if (lib->leak_detective)
{ /* keep handle to report leaks properly */
entry->handle = NULL;
}
+#endif
unregister_features(this, entry);
plugin_entry_destroy(entry);
}
.features = hashlist_create(
(hashtable_hash_t)registered_feature_hash,
(hashtable_equals_t)registered_feature_equals, 64),
- .get_features = dlsym(RTLD_DEFAULT, "plugin_loader_feature_filter"),
);
+#ifdef HAVE_DLADDR
+ this->get_features = dlsym(RTLD_DEFAULT, "plugin_loader_feature_filter");
+#endif
+
if (!this->get_features)
{
this->get_features = get_features_default;