"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/yvalve/PluginManager.cpp" between
Firebird-3.0.2.32703-0.tar.bz2 and Firebird-3.0.4.33054-0.tar.bz2

About: Firebird is a relational database offering many ANSI SQL standard features.

PluginManager.cpp  (Firebird-3.0.2.32703-0.tar.bz2):PluginManager.cpp  (Firebird-3.0.4.33054-0.tar.bz2)
skipping to change at line 387 skipping to change at line 387
else if (next) else if (next)
{ {
next->resetCleanup(c); next->resetCleanup(c);
} }
else else
{ {
gds__log("Failed to reset cleanup %p\n", c); gds__log("Failed to reset cleanup %p\n", c);
} }
} }
void threadDetach()
{
if (cleanup)
cleanup->threadDetach();
if (next)
next->threadDetach();
}
private: private:
~PluginModule() ~PluginModule()
{ {
if (next) if (next)
{ {
next->prev = prev; next->prev = prev;
} }
*prev = next; *prev = next;
if (cleanup) if (cleanup)
skipping to change at line 490 skipping to change at line 498
return findPluginConfig(pluginLoaderConfig, confName); return findPluginConfig(pluginLoaderConfig, confName);
} }
const PluginModule* getPluggedModule() const throw() const PluginModule* getPluggedModule() const throw()
{ {
return module; return module;
} }
IPluginBase* factory(IFirebirdConf *iFirebirdConf); IPluginBase* factory(IFirebirdConf *iFirebirdConf);
~ConfiguredPlugin();
const char* getPlugName() const char* getPlugName()
{ {
return plugName.c_str(); return plugName.c_str();
} }
void setReleaseDelay(ISC_UINT64 microSeconds) throw() void setReleaseDelay(ISC_UINT64 microSeconds) throw()
{ {
#ifdef DEBUG_PLUGINS #ifdef DEBUG_PLUGINS
fprintf(stderr, "Set delay for ConfiguredPlugin %s:%p\n", plugName.c_str(), this); fprintf(stderr, "Set delay for ConfiguredPlugin %s:%p\n", plugName.c_str(), this);
#endif #endif
skipping to change at line 517 skipping to change at line 523
return delay; return delay;
} }
// ITimer implementation // ITimer implementation
void handler() void handler()
{ } { }
int release(); int release();
private: private:
~ConfiguredPlugin();
RefPtr<PluginModule> module; RefPtr<PluginModule> module;
unsigned int regPlugin; unsigned int regPlugin;
RefPtr<ConfigFile> pluginLoaderConfig; RefPtr<ConfigFile> pluginLoaderConfig;
PathName confName; PathName confName;
PathName plugName; PathName plugName;
static const FB_UINT64 DEFAULT_DELAY = 1000000 * 60; / / 1 min static const FB_UINT64 DEFAULT_DELAY = 1000000 * 60; / / 1 min
FB_UINT64 delay; FB_UINT64 delay;
}; };
skipping to change at line 679 skipping to change at line 687
} }
Mutex mutex; // locked by this class' destructor and by objects t hat use the plugins var below. Mutex mutex; // locked by this class' destructor and by objects t hat use the plugins var below.
Semaphore* wakeIt; Semaphore* wakeIt;
}; };
GlobalPtr<PluginsMap> plugins; GlobalPtr<PluginsMap> plugins;
ConfiguredPlugin::~ConfiguredPlugin() ConfiguredPlugin::~ConfiguredPlugin()
{ {
MutexLockGuard g(plugins->mutex, FB_FUNCTION);
if (!destroyingPluginsMap) if (!destroyingPluginsMap)
{ {
plugins->remove(MapKey(module->getPlugin(regPlugin).type, plugName)); plugins->remove(MapKey(module->getPlugin(regPlugin).type, plugName));
} }
fb_assert(!plugins->wakeIt); fb_assert(!plugins->wakeIt);
if (module != builtin) if (module != builtin)
{ {
unsigned int type = module->getPlugin(regPlugin).type; unsigned int type = module->getPlugin(regPlugin).type;
if (--(byTypeCounters->get(type).counter) == 0) if (--(byTypeCounters->get(type).counter) == 0)
skipping to change at line 715 skipping to change at line 725
{ {
if (next) if (next)
{ {
next->prev = &next; next->prev = &next;
} }
*prev = this; *prev = this;
} }
int ConfiguredPlugin::release() int ConfiguredPlugin::release()
{ {
MutexLockGuard g(plugins->mutex, FB_FUNCTION);
int x = --refCounter; int x = --refCounter;
#ifdef DEBUG_PLUGINS #ifdef DEBUG_PLUGINS
fprintf(stderr, "ConfiguredPlugin::release %s %d\n", plugName.c_s tr(), x); fprintf(stderr, "ConfiguredPlugin::release %s %d\n", plugName.c_s tr(), x);
#endif #endif
if (x == 0) if (x == 0)
{ {
delete this; delete this;
return 0; return 0;
skipping to change at line 866 skipping to change at line 874
// ************************************* // // ************************************* //
void PluginSet::next(CheckStatusWrapper* status) void PluginSet::next(CheckStatusWrapper* status)
{ {
try try
{ {
if (currentPlugin.hasData()) if (currentPlugin.hasData())
{ {
currentPlugin = NULL; currentPlugin = NULL;
} }
// Avoid concurrent load of the same module
static Static<Mutex> loadModuleMutex;
MutexLockGuard lmGuard(*(&loadModuleMutex), FB_FUNCTION);
MutexLockGuard g(plugins->mutex, FB_FUNCTION); MutexLockGuard g(plugins->mutex, FB_FUNCTION);
while (currentName.getWord(namesList, " \t,;")) while (currentName.getWord(namesList, " \t,;"))
{ {
// First check - may be currentName is present am ong already configured plugins // First check - may be currentName is present am ong already configured plugins
ConfiguredPlugin* tmp = NULL; ConfiguredPlugin* tmp = NULL;
if (plugins->get(MapKey(interfaceType, currentNam e), tmp)) if (plugins->get(MapKey(interfaceType, currentNam e), tmp))
{ {
currentPlugin = tmp; currentPlugin = tmp;
break; break;
} }
// setup loadinfo // setup loadinfo
PluginLoadInfo info(currentName.c_str()); PluginLoadInfo info(currentName.c_str());
// Check if module is loaded and load it if neede d // Check if module is loaded and load it if neede d
RefPtr<PluginModule> m(modules->findModule(info.c urModule)); RefPtr<PluginModule> m(modules->findModule(info.c urModule));
if (!m.hasData() && !flShutdown) if (!m.hasData() && !flShutdown)
{ {
MutexUnlockGuard cout(plugins->mutex, FB_ FUNCTION);
m = loadModule(info); m = loadModule(info);
} }
if (!m.hasData()) if (!m.hasData())
{ {
continue; continue;
} }
int r = m->findPlugin(interfaceType, info.regName ); int r = m->findPlugin(interfaceType, info.regName );
if (r < 0) if (r < 0)
{ {
skipping to change at line 914 skipping to change at line 927
} }
catch (const Firebird::Exception& ex) catch (const Firebird::Exception& ex)
{ {
ex.stuffException(status); ex.stuffException(status);
} }
} }
RefPtr<PluginModule> PluginSet::loadModule(const PluginLoadInfo& info) RefPtr<PluginModule> PluginSet::loadModule(const PluginLoadInfo& info)
{ {
PathName fixedModuleName(info.curModule); PathName fixedModuleName(info.curModule);
ISC_STATUS_ARRAY statusArray;
ModuleLoader::Module* module = ModuleLoader::loadModule(fixedModu leName); ModuleLoader::Module* module = ModuleLoader::loadModule(statusArr ay, fixedModuleName);
if (!module && !ModuleLoader::isLoadableModule(fixedModuleName)) if (!module && !ModuleLoader::isLoadableModule(fixedModuleName))
{ {
ModuleLoader::doctorModuleExtension(fixedModuleName); ModuleLoader::doctorModuleExtension(fixedModuleName);
module = ModuleLoader::loadModule(fixedModuleName); module = ModuleLoader::loadModule(statusArray, fixedModul eName);
} }
if (!module) if (!module)
{ {
if (ModuleLoader::isLoadableModule(fixedModuleName)) if (ModuleLoader::isLoadableModule(fixedModuleName))
{ {
loadError(Arg::Gds(isc_pman_module_bad) << fixedM loadError(Arg::Gds(isc_pman_module_bad) << fixedM
oduleName); oduleName <<
Arg::StatusVector(statusArray));
} }
if (info.required) if (info.required)
{ {
loadError(Arg::Gds(isc_pman_module_notfound) << f loadError(Arg::Gds(isc_pman_module_notfound) << f
ixedModuleName); ixedModuleName <<
Arg::StatusVector(statusArray));
} }
return RefPtr<PluginModule>(NULL); return RefPtr<PluginModule>(NULL);
} }
RefPtr<PluginModule> rc(FB_NEW PluginModule(module, info.curModul e)); RefPtr<PluginModule> rc(FB_NEW PluginModule(module, info.curModul e));
typedef void PluginEntrypoint(IMaster* masterInterface); typedef void PluginEntrypoint(IMaster* masterInterface);
PluginEntrypoint* startModule; PluginEntrypoint* startModule;
if (module->findSymbol(STRINGIZE(FB_PLUGIN_ENTRY_POINT), startMod ule)) if (module->findSymbol(STRINGIZE(FB_PLUGIN_ENTRY_POINT), startMod ule))
{ {
skipping to change at line 1071 skipping to change at line 1087
} }
IPluginSet* PluginManager::getPlugins(CheckStatusWrapper* status, unsigned int i nterfaceType, IPluginSet* PluginManager::getPlugins(CheckStatusWrapper* status, unsigned int i nterfaceType,
const char* namesList, IFirebirdConf* firebirdConf) const char* namesList, IFirebirdConf* firebirdConf)
{ {
try try
{ {
static InitMutex<BuiltinRegister> registerBuiltinPlugins("Registe rBuiltinPlugins"); static InitMutex<BuiltinRegister> registerBuiltinPlugins("Registe rBuiltinPlugins");
registerBuiltinPlugins.init(); registerBuiltinPlugins.init();
MutexLockGuard g(plugins->mutex, FB_FUNCTION);
IPluginSet* rc = FB_NEW PluginSet(interfaceType, namesList, fireb irdConf); IPluginSet* rc = FB_NEW PluginSet(interfaceType, namesList, fireb irdConf);
rc->addRef(); rc->addRef();
return rc; return rc;
} }
catch (const Exception& ex) catch (const Exception& ex)
{ {
ex.stuffException(status); ex.stuffException(status);
return NULL; return NULL;
} }
} }
void PluginManager::releasePlugin(IPluginBase* plugin) void PluginManager::releasePlugin(IPluginBase* plugin)
{ {
IReferenceCounted* parent = plugin->getOwner(); IReferenceCounted* parent = plugin->getOwner();
if (plugin->release() == 0) if (plugin->release() == 0)
{ {
///fb_assert(parent); ///fb_assert(parent);
if (parent) if (parent)
{ {
MutexLockGuard g(plugins->mutex, FB_FUNCTION);
parent->release(); parent->release();
MutexLockGuard g(plugins->mutex, FB_FUNCTION);
if (plugins->wakeIt) if (plugins->wakeIt)
{ {
plugins->wakeIt->release(); plugins->wakeIt->release();
plugins->wakeIt = NULL; plugins->wakeIt = NULL;
} }
} }
} }
} }
IConfig* PluginManager::getConfig(CheckStatusWrapper* status, const char* filena me) IConfig* PluginManager::getConfig(CheckStatusWrapper* status, const char* filena me)
skipping to change at line 1158 skipping to change at line 1172
} }
#endif #endif
} }
if (semPtr) if (semPtr)
{ {
semPtr->enter(); semPtr->enter();
} }
} }
void PluginManager::threadDetach()
{
MutexLockGuard g(plugins->mutex, FB_FUNCTION);
if (modules)
modules->threadDetach();
}
} // namespace Firebird } // namespace Firebird
namespace { namespace {
class DirCache class DirCache
{ {
public: public:
explicit DirCache(MemoryPool &p) explicit DirCache(MemoryPool &p)
: cache(p) : cache(p)
{ {
 End of changes. 16 change blocks. 
14 lines changed or deleted 35 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)