diff --git a/src/jrd/Database.cpp b/src/jrd/Database.cpp index f01dfb7529..8a66048426 100644 --- a/src/jrd/Database.cpp +++ b/src/jrd/Database.cpp @@ -231,6 +231,19 @@ namespace Jrd dbb_flags &= ~(DBB_sweep_in_progress | DBB_sweep_starting); } + void Database::registerModule(Module& module) + { + Sync sync(&dbb_modules_sync, FB_FUNCTION); + sync.lock(SYNC_SHARED); + if (dbb_modules.exist(module)) + return; + + sync.unlock(); + sync.lock(SYNC_EXCLUSIVE); + if (!dbb_modules.exist(module)) + dbb_modules.add(module); + } + void Database::SharedCounter::shutdown(thread_db* tdbb) { for (size_t i = 0; i < TOTAL_ITEMS; i++) diff --git a/src/jrd/Database.h b/src/jrd/Database.h index d15554e727..b8be9f1dba 100644 --- a/src/jrd/Database.h +++ b/src/jrd/Database.h @@ -398,7 +398,11 @@ public: MonitoringData* dbb_monitoring_data; // monitoring data +private: + Firebird::SyncObject dbb_modules_sync; DatabaseModules dbb_modules; // external function/filter modules + +public: ExtEngineManager dbb_extManager; // external engine manager Firebird::SyncObject dbb_flush_count_mutex; @@ -497,6 +501,8 @@ public: void deletePool(MemoryPool* pool); + void registerModule(Module&); + private: Database(MemoryPool* p, Firebird::IPluginConfig* pConf, bool shared) : dbb_permanent(p), diff --git a/src/jrd/Function.epp b/src/jrd/Function.epp index 3ca90daa58..357ee9ecf6 100644 --- a/src/jrd/Function.epp +++ b/src/jrd/Function.epp @@ -389,7 +389,7 @@ Function* Function::loadMetadata(thread_db* tdbb, USHORT id, bool noscan, USHORT if (!X.RDB$MODULE_NAME.NULL && !X.RDB$ENTRYPOINT.NULL) { function->fun_entrypoint = - Module::lookup(X.RDB$MODULE_NAME, X.RDB$ENTRYPOINT, dbb->dbb_modules); + Module::lookup(X.RDB$MODULE_NAME, X.RDB$ENTRYPOINT, dbb); // Could not find a function with given MODULE, ENTRYPOINT. // Try the list of internally implemented functions. diff --git a/src/jrd/flu.cpp b/src/jrd/flu.cpp index 60d5d7e735..9f5ea61ceb 100644 --- a/src/jrd/flu.cpp +++ b/src/jrd/flu.cpp @@ -165,7 +165,7 @@ namespace Jrd } - FPTR_INT Module::lookup(const char* module, const char* name, DatabaseModules& interest) + FPTR_INT Module::lookup(const char* module, const char* name, Database* dbb) { // Try to find loadable module Module m = lookupModule(module); @@ -178,12 +178,7 @@ namespace Jrd terminate_at_space(symbol, name); void* rc = m.lookupSymbol(symbol); if (rc) - { - if (!interest.exist(m)) - { - interest.add(m); - } - } + dbb->registerModule(m); return (FPTR_INT)rc; } diff --git a/src/jrd/flu.h b/src/jrd/flu.h index 9faabd0926..ff6cd60e8a 100644 --- a/src/jrd/flu.h +++ b/src/jrd/flu.h @@ -35,6 +35,8 @@ namespace Jrd { + class Database; + class Module { private: @@ -105,7 +107,7 @@ namespace Jrd ~Module(); // used for UDF/BLOB Filter - static FPTR_INT lookup(const char*, const char*, Firebird::SortedObjectsArray&); + static FPTR_INT lookup(const char*, const char*, Database*); bool operator>(const Module &im) const; diff --git a/src/jrd/met.epp b/src/jrd/met.epp index 89927439ff..d2ea63e105 100644 --- a/src/jrd/met.epp +++ b/src/jrd/met.epp @@ -2264,7 +2264,7 @@ BlobFilter* MET_lookup_filter(thread_db* tdbb, SSHORT from, SSHORT to) X.RDB$OUTPUT_SUB_TYPE EQ to { filter = (FPTR_BFILTER_CALLBACK) - Module::lookup(X.RDB$MODULE_NAME, X.RDB$ENTRYPOINT, dbb->dbb_modules); + Module::lookup(X.RDB$MODULE_NAME, X.RDB$ENTRYPOINT, dbb); if (filter) { blf = FB_NEW_POOL(*dbb->dbb_permanent) BlobFilter(*dbb->dbb_permanent);