@@ -207,15 +207,15 @@ Connection* Manager::getConnection(thread_db* tdbb, const string& dataSource,
207207
208208 Provider* prv = getProvider (prvName);
209209
210- const bool isCurrent = (prvName == INTERNAL_PROVIDER_NAME) &&
210+ const bool isCurrentAtt = (prvName == INTERNAL_PROVIDER_NAME) &&
211211 isCurrentAccount (att->att_user , user, pwd, role);
212212
213213 ClumpletWriter dpb (ClumpletReader::dpbList, MAX_DPB_SIZE);
214- if (!isCurrent )
214+ if (!isCurrentAtt )
215215 prv->generateDPB (tdbb, dpb, user, pwd, role);
216216
217217 // look up at connections already bound to current attachment
218- Connection* conn = prv->getBoundConnection (tdbb, dbName, dpb, tra_scope);
218+ Connection* conn = prv->getBoundConnection (tdbb, dbName, dpb, tra_scope, isCurrentAtt );
219219 if (conn)
220220 return conn;
221221
@@ -226,7 +226,7 @@ Connection* Manager::getConnection(thread_db* tdbb, const string& dataSource,
226226
227227 ULONG hash = 0 ;
228228
229- if (!isCurrent )
229+ if (!isCurrentAtt )
230230 {
231231 CryptHash ch (att->att_crypt_callback );
232232 hash = DefaultHash<UCHAR>::hash (dbName.c_str (), dbName.length (), MAX_ULONG) +
@@ -255,7 +255,7 @@ Connection* Manager::getConnection(thread_db* tdbb, const string& dataSource,
255255 {
256256 // finally, create new connection
257257 conn = prv->createConnection (tdbb, dbName, dpb, tra_scope);
258- if (!isCurrent )
258+ if (!isCurrentAtt )
259259 m_connPool->addConnection (tdbb, conn, hash);
260260 }
261261
@@ -358,7 +358,10 @@ Connection* Provider::createConnection(thread_db* tdbb,
358358 const PathName& dbName, ClumpletReader& dpb, TraScope tra_scope)
359359{
360360 Connection* conn = doCreateConnection ();
361- conn->setup (dbName, dpb, tdbb->getAttachment ()->att_crypt_callback );
361+ conn->setup (dbName, dpb);
362+ if (!conn->isCurrent ())
363+ conn->setCallbackRedirect (tdbb->getAttachment ()->att_crypt_callback );
364+
362365 try
363366 {
364367 conn->attach (tdbb);
@@ -390,11 +393,13 @@ void Provider::bindConnection(thread_db* tdbb, Connection* conn)
390393
391394Connection* Provider::getBoundConnection (Jrd::thread_db* tdbb,
392395 const Firebird::PathName& dbName, Firebird::ClumpletReader& dpb,
393- TraScope tra_scope)
396+ TraScope tra_scope, bool isCurrentAtt )
394397{
395398 Database* dbb = tdbb->getDatabase ();
396399 Attachment* att = tdbb->getAttachment ();
397- CryptHash ch (att->att_crypt_callback );
400+ CryptHash ch;
401+ if (!isCurrentAtt)
402+ ch.assign (att->att_crypt_callback );
398403
399404 MutexLockGuard guard (m_mutex, FB_FUNCTION);
400405
@@ -590,14 +595,12 @@ Connection::Connection(Provider& prov) :
590595{
591596}
592597
593- void Connection::setup (const PathName& dbName, const ClumpletReader& dpb, ICryptKeyCallback* attCallback )
598+ void Connection::setup (const PathName& dbName, const ClumpletReader& dpb)
594599{
595600 m_dbName = dbName;
596601
597602 m_dpb.clear ();
598603 m_dpb.add (dpb.getBuffer (), dpb.getBufferLength ());
599-
600- m_cryptCallbackRedir.setRedirect (attCallback);
601604}
602605
603606void Connection::deleteConnection (thread_db* tdbb, Connection* conn)
@@ -2668,7 +2671,7 @@ void CryptHash::assign(ICryptKeyCallback* callback)
26682671
26692672bool CryptHash::operator ==(const CryptHash& h) const
26702673{
2671- return isValid () && h.isValid () && m_value == h.m_value ;
2674+ return ( isValid () == h.isValid ()) && ( m_value == h.m_value ) ;
26722675}
26732676
26742677
0 commit comments