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

Separated shutdown (mostly for locks) from destruction.

This commit is contained in:
dimitr 2013-11-13 07:44:50 +00:00
parent 9d721140ef
commit fe23598a23
4 changed files with 17 additions and 26 deletions

View File

@ -141,6 +141,8 @@ namespace Jrd {
CryptoManager::~CryptoManager()
{
delete stateLock;
delete threadLock;
}
void CryptoManager::terminateCryptThread(thread_db*)
@ -163,11 +165,7 @@ namespace Jrd {
cryptPlugin = NULL;
}
if (stateLock)
{
LCK_release(tdbb, stateLock);
stateLock = NULL;
}
LCK_release(tdbb, stateLock);
}
void CryptoManager::takeStateLock(thread_db* tdbb)

View File

@ -83,34 +83,27 @@ GlobalRWLock::GlobalRWLock(thread_db* tdbb, MemoryPool& p, lck_t lckType,
GlobalRWLock::~GlobalRWLock()
{
if (cachedLock)
shutdownLock();
delete cachedLock;
}
void GlobalRWLock::shutdownLock()
void GlobalRWLock::shutdownLock(thread_db* tdbb)
{
thread_db* tdbb = JRD_get_thread_data();
SET_TDBB(tdbb);
Attachment::CheckoutLockGuard counterGuard(tdbb->getAttachment(), counterMutex,
FB_FUNCTION, true);
Attachment* const att = tdbb->getAttachment();
Attachment::CheckoutLockGuard counterGuard(att, counterMutex, FB_FUNCTION, true);
COS_TRACE(("(%p)->shutdownLock readers(%d), blocking(%d), pendingWriters(%d), currentWriter(%d), lck_physical(%d)",
this, readers, blocking, pendingWriters, currentWriter, cachedLock->lck_physical));
if (!cachedLock)
return;
LCK_release(tdbb, cachedLock);
delete cachedLock;
cachedLock = NULL;
}
bool GlobalRWLock::lockWrite(thread_db* tdbb, SSHORT wait)
{
SET_TDBB(tdbb);
Attachment* att = tdbb->getAttachment();
Attachment* const att = tdbb->getAttachment();
{ // scope 1
Attachment::CheckoutLockGuard counterGuard(att, counterMutex, FB_FUNCTION, true);
@ -191,7 +184,7 @@ void GlobalRWLock::unlockWrite(thread_db* tdbb)
{
SET_TDBB(tdbb);
Attachment* att = tdbb->getAttachment();
Attachment* const att = tdbb->getAttachment();
Attachment::CheckoutLockGuard counterGuard(att, counterMutex, FB_FUNCTION, true);
COS_TRACE(("(%p)->unlockWrite readers(%d), blocking(%d), pendingWriters(%d), currentWriter(%d), lck_physical(%d)",
@ -219,7 +212,7 @@ bool GlobalRWLock::lockRead(thread_db* tdbb, SSHORT wait, const bool queueJump)
{
SET_TDBB(tdbb);
Attachment* att = tdbb->getAttachment();
Attachment* const att = tdbb->getAttachment();
bool needFetch;
@ -294,7 +287,7 @@ void GlobalRWLock::unlockRead(thread_db* tdbb)
{
SET_TDBB(tdbb);
Attachment* att = tdbb->getAttachment();
Attachment* const att = tdbb->getAttachment();
Attachment::CheckoutLockGuard counterGuard(att, counterMutex, FB_FUNCTION, true);
COS_TRACE(("(%p)->unlockRead readers(%d), blocking(%d), pendingWriters(%d), currentWriter(%d), lck_physical(%d)",
@ -317,7 +310,7 @@ void GlobalRWLock::unlockRead(thread_db* tdbb)
bool GlobalRWLock::tryReleaseLock(thread_db* tdbb)
{
Attachment* att = tdbb->getAttachment();
Attachment* const att = tdbb->getAttachment();
Attachment::CheckoutLockGuard counterGuard(att, counterMutex, FB_FUNCTION, true);
COS_TRACE(("(%p)->tryReleaseLock readers(%d), blocking(%d), pendingWriters(%d), currentWriter(%d), lck_physical(%d)",

View File

@ -69,7 +69,7 @@ public:
bool lockRead(thread_db* tdbb, SSHORT wait, const bool queueJump = false);
void unlockRead(thread_db* tdbb);
bool tryReleaseLock(thread_db* tdbb);
void shutdownLock();
void shutdownLock(thread_db* tdbb);
protected:
// Flag to indicate that somebody is waiting via lock manager.

View File

@ -861,11 +861,11 @@ bool BackupManager::actualizeState(thread_db* tdbb)
return true;
}
void BackupManager::shutdown(thread_db* /*tdbb*/)
void BackupManager::shutdown(thread_db* tdbb)
{
shutDown = true;
closeDelta();
stateLock->shutdownLock();
allocLock->shutdownLock();
stateLock->shutdownLock(tdbb);
allocLock->shutdownLock(tdbb);
}