Skip to content

Commit b4386db

Browse files
committed
Fixed CORE-6441: Srp plugin keeps connection after database has been removed for ~10 seconds (SS and SC)
1 parent 500758f commit b4386db

5 files changed

Lines changed: 31 additions & 8 deletions

File tree

src/auth/SecDbCache.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,23 @@ void PluginDatabases::getInstance(IPluginConfig* pluginConfig, RefPtr<CachedSecu
7171

7272
{ // guard scope
7373
MutexLockGuard g(arrayMutex, FB_FUNCTION);
74-
for (unsigned int i = 0; i < dbArray.getCount(); ++i)
74+
for (unsigned int i = 0; i < dbArray.getCount(); )
7575
{
7676
if (secDbName == dbArray[i]->secureDbName)
7777
{
78-
instance = dbArray[i];
79-
break;
78+
CachedSecurityDatabase* fromCache = dbArray[i];
79+
if (fromCache->secDb->test())
80+
{
81+
instance = fromCache;
82+
break;
83+
}
84+
else
85+
{
86+
dbArray.remove(i);
87+
continue;
88+
}
8089
}
90+
++i;
8191
}
8292

8393
if (!instance)
@@ -147,7 +157,7 @@ void PluginDatabases::handler(CachedSecurityDatabase* tgt)
147157
const ISC_STATUS* status = st.begin();
148158
if (status[0] == 1 && status[1] != isc_att_shutdown)
149159
{
150-
iscLogStatus("Legacy security database timer handler", status);
160+
iscLogStatus("Security database timer handler", status);
151161
}
152162
}
153163
}

src/auth/SecDbCache.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class VSecDb
4949
}
5050

5151
virtual bool lookup(void* inMsg, void* outMsg) = 0;
52+
virtual bool test() = 0;
5253
};
5354

5455

src/auth/SecureRemotePassword/server/SrpServer.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ class SrpServer : public StdPlugin<IServerImpl<SrpServer, CheckStatusWrapper> >
109109
class SecurityDatabase : public VSecDb
110110
{
111111
public:
112-
bool lookup(void* inMsg, void* outMsg)
112+
// VSecDb implementation
113+
bool lookup(void* inMsg, void* outMsg) override
113114
{
114115
FbLocalStatus status;
115116

@@ -120,6 +121,14 @@ class SecurityDatabase : public VSecDb
120121
return false; // safe default
121122
}
122123

124+
bool test() override
125+
{
126+
FbLocalStatus status;
127+
128+
att->ping(&status);
129+
return !(status->getState() & IStatus::STATE_ERRORS);
130+
}
131+
123132
// This 2 are needed to satisfy temporarily different calling requirements
124133
static int shutdown(const int, const int, void*)
125134
{

src/auth/SecurityDatabase/LegacyServer.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,12 @@ class SecurityDatabaseServer FB_FINAL :
146146
class SecurityDatabase : public VSecDb
147147
{
148148
public:
149-
bool lookup(void* inMsg, void* outMsg);
149+
bool lookup(void* inMsg, void* outMsg) override;
150+
151+
bool test() override
152+
{
153+
return fb_ping(status, &lookup_db) == FB_SUCCESS;
154+
}
150155

151156
// This 2 are needed to satisfy temporarily different calling requirements
152157
static int shutdown(const int, const int, void*)

src/jrd/ExtEngineManager.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -603,8 +603,6 @@ ExtEngineManager::ExternalContextImpl::ExternalContextImpl(thread_db* tdbb,
603603

604604
clientCharSet = INTL_charset_lookup(tdbb, internalAttachment->att_client_charset)->getName();
605605

606-
internalAttachment->getStable()->addRef();
607-
608606
externalAttachment = MasterInterfacePtr()->registerAttachment
609607
(internalAttachment->getProvider(), internalAttachment->getInterface());
610608
}

0 commit comments

Comments
 (0)