From 3b64000b9f204e65dc2477dedfbd742625d47f6a Mon Sep 17 00:00:00 2001 From: Popa Marius Adrian Date: Tue, 20 Oct 2026 23:52:44 +0300 Subject: [PATCH] Fix #9214: Avoid bogus "NoDefault" plugin load on every attach and unnecessary loadModuleMutex locks 1. In ClntAuthBlock::ClientCrypt (src/remote/remote.h), pass "" instead of "NoDefault" to GetPlugins. GetPlugins does not treat "NoDefault" specially, so PluginSet treated it as a literal plugin name and attempted to LoadLibrary/dlopen "plugins/NoDefault" while holding loadModuleMutex on every attach before ClientCrypt::create() replaced the iterator with the configured KeyHolderPlugin. 2. In PluginSet::next() (src/yvalve/PluginManager.cpp), only acquire loadModuleMutex when a plugin is not already present in the configured plugins map, and avoid acquiring any mutex when namesList is empty. --- src/remote/remote.h | 2 +- src/yvalve/PluginManager.cpp | 24 +++++++++++++++++------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/remote/remote.h b/src/remote/remote.h index 22cc61c377c..e0a08f69620 100644 --- a/src/remote/remote.h +++ b/src/remote/remote.h @@ -1078,7 +1078,7 @@ class ClntAuthBlock final : { public: ClientCrypt() - : pluginItr(Firebird::IPluginManager::TYPE_KEY_HOLDER, "NoDefault"), + : pluginItr(Firebird::IPluginManager::TYPE_KEY_HOLDER, ""), currentIface(nullptr), afterIface(nullptr), triedPlugins(getPool()) { } diff --git a/src/yvalve/PluginManager.cpp b/src/yvalve/PluginManager.cpp index 7516b9b613d..f1f25c7943f 100644 --- a/src/yvalve/PluginManager.cpp +++ b/src/yvalve/PluginManager.cpp @@ -905,16 +905,26 @@ namespace currentPlugin = NULL; } - // Avoid concurrent load of the same module - static Static loadModuleMutex; - MutexLockGuard lmGuard(*(&loadModuleMutex), FB_FUNCTION); - - MutexLockGuard g(plugins->mutex, FB_FUNCTION); - while (currentName.getWord(namesList, " \t,;")) { - // First check - may be currentName is present among already configured plugins ConfiguredPlugin* tmp = NULL; + { + MutexLockGuard g(plugins->mutex, FB_FUNCTION); + + // First check - may be currentName is present among already configured plugins + if (plugins->get(MapKey(interfaceType, currentName), tmp)) + { + currentPlugin = tmp; + break; + } + } + + // Avoid concurrent load of the same module + static Static loadModuleMutex; + MutexLockGuard lmGuard(*(&loadModuleMutex), FB_FUNCTION); + + MutexLockGuard g(plugins->mutex, FB_FUNCTION); + if (plugins->get(MapKey(interfaceType, currentName), tmp)) { currentPlugin = tmp;