MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / getInstance

Method getInstance

src/auth/SecDbCache.cpp:54–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52
53
54void PluginDatabases::getInstance(IPluginConfig* pluginConfig, CachedSecurityDatabase::Instance& instance)
55{
56 // Determine sec.db name based on existing config
57 PathName secDbName;
58 { // config scope
59 FbLocalStatus s;
60 RefPtr<IFirebirdConf> config(REF_NO_INCR, pluginConfig->getFirebirdConf(&s));
61 check(&s);
62
63 static GlobalPtr<ConfigKeys> keys;
64 unsigned int secDbKey = keys->getKey(config, "SecurityDatabase");
65 const char* tmp = config->asString(secDbKey);
66 if (!tmp)
67 Arg::Gds(isc_secdb_name).raise();
68
69 secDbName = tmp;
70 }
71
72 { // guard scope
73 MutexLockGuard g(arrayMutex, FB_FUNCTION);
74 for (unsigned int i = 0; i < dbArray.getCount(); )
75 {
76 if (secDbName == dbArray[i]->secureDbName)
77 {
78 CachedSecurityDatabase* fromCache = dbArray[i];
79 // if element is just created or test passed we can use it
80 if ((!fromCache->secDb) || fromCache->secDb->test())
81 {
82 instance.set(fromCache);
83 break;
84 }
85 else
86 {
87 dbArray.remove(i);
88 continue;
89 }
90 }
91 ++i;
92 }
93
94 if (!instance)
95 {
96 instance.set(FB_NEW CachedSecurityDatabase(this, secDbName));
97 secDbName.copyTo(instance->secureDbName, sizeof(instance->secureDbName));
98 dbArray.add(instance);
99 instance->addRef();
100 }
101 }
102}
103
104int PluginDatabases::shutdown()
105{

Callers 2

authenticateMethod · 0.45
authenticateMethod · 0.45

Calls 14

GdsClass · 0.85
checkFunction · 0.50
getFirebirdConfMethod · 0.45
getKeyMethod · 0.45
asStringMethod · 0.45
raiseMethod · 0.45
getCountMethod · 0.45
testMethod · 0.45
setMethod · 0.45
removeMethod · 0.45
copyToMethod · 0.45

Tested by

no test coverage detected