return plugin;
}
+static void close_plugin(Plugin *plugin)
+{
+ if (plugin->file) {
+ Dmsg1(50, "Got plugin=%s but not accepted.\n", plugin->file);
+ }
+ if (plugin->unloadPlugin) {
+ plugin->unloadPlugin();
+ }
+ if (plugin->pHandle) {
+ dlclose(plugin->pHandle);
+ }
+ if (plugin->file) {
+ free(plugin->file);
+ }
+ free(plugin);
+}
/*
* Load all the plugins in the specified directory.
fname.c_str(), NPRT(dlerror()));
Dmsg2(dbglvl, "Plugin load %s failed: ERR=%s\n", fname.c_str(),
NPRT(dlerror()));
- goto get_out;
+ close_plugin(plugin);
+ continue;
}
/* Get two global entry points */
fname.c_str(), NPRT(dlerror()));
Dmsg2(dbglvl, "Lookup of loadPlugin in plugin %s failed: ERR=%s\n",
fname.c_str(), NPRT(dlerror()));
- goto get_out;
+ close_plugin(plugin);
+ continue;
}
plugin->unloadPlugin = (t_unloadPlugin)dlsym(plugin->pHandle, "unloadPlugin");
if (!plugin->unloadPlugin) {
fname.c_str(), NPRT(dlerror()));
Dmsg2(dbglvl, "Lookup of unloadPlugin in plugin %s failed: ERR=%s\n",
fname.c_str(), NPRT(dlerror()));
- goto get_out;
+ close_plugin(plugin);
+ continue;
}
/* Initialize the plugin */
if (loadPlugin(binfo, bfuncs, &plugin->pinfo, &plugin->pfuncs) != bRC_OK) {
- goto get_out;
+ close_plugin(plugin);
+ continue;
}
if (!is_plugin_compatible) {
Dmsg0(50, "Plugin compatibility pointer not set.\n");
} else if (!is_plugin_compatible(plugin)) {
- goto get_out;
+ close_plugin(plugin);
+ continue;
}
found = true; /* found a plugin */
get_out:
if (!found && plugin) {
- if (plugin->file) {
- Dmsg1(50, "Got plugin=%s but not accepted.\n", plugin->file);
- }
- if (plugin->unloadPlugin) {
- plugin->unloadPlugin();
- }
- if (plugin->pHandle) {
- dlclose(plugin->pHandle);
- }
- if (plugin->file) {
- free(plugin->file);
- }
- free(plugin);
+ close_plugin(plugin);
}
if (entry) {
free(entry);