8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 07:23:04 +01:00

Fixed races during shmem reattaching

This commit is contained in:
Dmitry Yemanov 2019-12-16 18:50:28 +03:00
parent 6c262aa30a
commit 2294d6573d
2 changed files with 5 additions and 2 deletions

View File

@ -175,6 +175,7 @@ void MonitoringData::detachSharedFile()
void MonitoringData::acquire()
{
m_localMutex.enter(FB_FUNCTION);
m_sharedMemory->mutexLock();
// Check for shared memory state consistency
@ -208,11 +209,11 @@ void MonitoringData::acquire()
FbLocalStatus statusVector;
if (!m_sharedMemory->remapFile(&statusVector, m_sharedMemory->getHeader()->allocated, false))
{
m_sharedMemory->mutexUnlock();
release();
status_exception::raise(&statusVector);
}
#else
m_sharedMemory->mutexUnlock();
release();
status_exception::raise(Arg::Gds(isc_montabexh));
#endif
}
@ -222,6 +223,7 @@ void MonitoringData::acquire()
void MonitoringData::release()
{
m_sharedMemory->mutexUnlock();
m_localMutex.leave();
}

View File

@ -344,6 +344,7 @@ private:
Firebird::string m_dbId;
Firebird::AutoPtr<Firebird::SharedMemory<MonitoringHeader> > m_sharedMemory;
Firebird::Mutex m_localMutex;
bool m_sharedFileCreated;
};