plugin-loader: Print an error message if plugin constructor is not found
This commit is contained in:
@@ -357,19 +357,12 @@ void plugin_constructor_register(char *name, void *constructor)
|
|||||||
* FAILED, if the plugin could not be constructed
|
* FAILED, if the plugin could not be constructed
|
||||||
*/
|
*/
|
||||||
static status_t create_plugin(private_plugin_loader_t *this, void *handle,
|
static status_t create_plugin(private_plugin_loader_t *this, void *handle,
|
||||||
char *name, bool integrity, bool critical,
|
char *name, char *create, bool integrity,
|
||||||
plugin_entry_t **entry)
|
bool critical, plugin_entry_t **entry)
|
||||||
{
|
{
|
||||||
char create[128];
|
|
||||||
plugin_t *plugin;
|
plugin_t *plugin;
|
||||||
plugin_constructor_t constructor = NULL;
|
plugin_constructor_t constructor = NULL;
|
||||||
|
|
||||||
if (snprintf(create, sizeof(create), "%s_plugin_create",
|
|
||||||
name) >= sizeof(create))
|
|
||||||
{
|
|
||||||
return FAILED;
|
|
||||||
}
|
|
||||||
translate(create, "-", "_");
|
|
||||||
#ifdef STATIC_PLUGIN_CONSTRUCTORS
|
#ifdef STATIC_PLUGIN_CONSTRUCTORS
|
||||||
if (plugin_constructors)
|
if (plugin_constructors)
|
||||||
{
|
{
|
||||||
@@ -416,11 +409,19 @@ static status_t create_plugin(private_plugin_loader_t *this, void *handle,
|
|||||||
static plugin_entry_t *load_plugin(private_plugin_loader_t *this, char *name,
|
static plugin_entry_t *load_plugin(private_plugin_loader_t *this, char *name,
|
||||||
char *file, bool critical)
|
char *file, bool critical)
|
||||||
{
|
{
|
||||||
|
char create[128];
|
||||||
plugin_entry_t *entry;
|
plugin_entry_t *entry;
|
||||||
void *handle;
|
void *handle;
|
||||||
int flag = RTLD_LAZY;
|
int flag = RTLD_LAZY;
|
||||||
|
|
||||||
switch (create_plugin(this, RTLD_DEFAULT, name, FALSE, critical, &entry))
|
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,
|
||||||
|
&entry))
|
||||||
{
|
{
|
||||||
case SUCCESS:
|
case SUCCESS:
|
||||||
this->plugins->insert_last(this->plugins, entry);
|
this->plugins->insert_last(this->plugins, entry);
|
||||||
@@ -430,6 +431,8 @@ static plugin_entry_t *load_plugin(private_plugin_loader_t *this, char *name,
|
|||||||
{ /* try to load the plugin from a file */
|
{ /* try to load the plugin from a file */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
DBG1(DBG_LIB, "plugin '%s': failed to load - %s not found and no "
|
||||||
|
"plugin file available", name, create);
|
||||||
/* fall-through */
|
/* fall-through */
|
||||||
default:
|
default:
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -461,10 +464,17 @@ static plugin_entry_t *load_plugin(private_plugin_loader_t *this, char *name,
|
|||||||
DBG1(DBG_LIB, "plugin '%s' failed to load: %s", name, dlerror());
|
DBG1(DBG_LIB, "plugin '%s' failed to load: %s", name, dlerror());
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (create_plugin(this, handle, name, TRUE, critical, &entry) != SUCCESS)
|
switch (create_plugin(this, handle, name, create, TRUE, critical, &entry))
|
||||||
{
|
{
|
||||||
dlclose(handle);
|
case SUCCESS:
|
||||||
return NULL;
|
break;
|
||||||
|
case NOT_FOUND:
|
||||||
|
DBG1(DBG_LIB, "plugin '%s': failed to load - %s not found", name,
|
||||||
|
create);
|
||||||
|
/* fall-through */
|
||||||
|
default:
|
||||||
|
dlclose(handle);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
entry->handle = handle;
|
entry->handle = handle;
|
||||||
this->plugins->insert_last(this->plugins, entry);
|
this->plugins->insert_last(this->plugins, entry);
|
||||||
|
|||||||
Reference in New Issue
Block a user