8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-22 16:43:03 +01:00

Fixed #7738: Crash on multiple connections/disconnections

This commit is contained in:
AlexPeshkoff 2023-09-06 13:40:07 +03:00
parent bdce8b1341
commit 8e61e1111d
2 changed files with 8 additions and 0 deletions

View File

@ -1633,6 +1633,10 @@ void CCH_init2(thread_db* tdbb)
Database* dbb = tdbb->getDatabase();
BufferControl* bcb = dbb->dbb_bcb;
// Avoid running CCH_init2() in 2 parallel threads
Firebird::MutexEnsureUnlock guard(bcb->bcb_threadStartup, FB_FUNCTION);
guard.enter();
if (!(bcb->bcb_flags & BCB_exclusive) || (bcb->bcb_flags & (BCB_cache_writer | BCB_writer_start)))
return;
@ -1653,6 +1657,7 @@ void CCH_init2(thread_db* tdbb)
{
// writer startup in progress
bcb->bcb_flags |= BCB_writer_start;
guard.leave();
try
{

View File

@ -142,6 +142,9 @@ public:
Firebird::SyncObject bcb_syncPrecedence;
Firebird::SyncObject bcb_syncLRU;
// If we make bcb_flags atomic this mutex will become unneeded: XCHG of bcb_flags is enough
Firebird::Mutex bcb_threadStartup;
typedef ThreadFinishSync<BufferControl*> BcbThreadSync;
static void cache_writer(BufferControl* bcb);