mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-22 21:23:04 +01:00
GlobalRWLock state should remain consistent in the case when fetch() returns false or throws.
This commit is contained in:
parent
9c9accde69
commit
3931b87474
@ -38,6 +38,7 @@
|
||||
#include "Attachment.h"
|
||||
#include "../common/classes/rwlock.h"
|
||||
#include "../common/classes/condition.h"
|
||||
#include "../common/classes/auto.h"
|
||||
|
||||
#ifdef COS_DEBUG
|
||||
#include <stdarg.h>
|
||||
@ -179,12 +180,20 @@ bool GlobalRWLock::lockWrite(thread_db* tdbb, SSHORT wait)
|
||||
|
||||
fb_assert(!currentWriter);
|
||||
|
||||
Cleanup writerFini([this]()
|
||||
{
|
||||
if (!currentWriter)
|
||||
writerFinished.notifyAll();
|
||||
});
|
||||
|
||||
const bool ret = fetch(tdbb);
|
||||
if (ret)
|
||||
currentWriter = true;
|
||||
|
||||
COS_TRACE(("(%p)->lockWrite end readers(%d), blocking(%d), pendingWriters(%d), currentWriter(%d), lck_physical(%d)",
|
||||
this, readers, blocking, pendingWriters, currentWriter, cachedLock->lck_physical));
|
||||
|
||||
return fetch(tdbb);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@ -279,12 +288,14 @@ bool GlobalRWLock::lockRead(thread_db* tdbb, SSHORT wait, const bool queueJump)
|
||||
{ // scope 2
|
||||
CheckoutLockGuard counterGuard(tdbb, counterMutex, FB_FUNCTION, true);
|
||||
--pendingLock;
|
||||
const bool ret = fetch(tdbb);
|
||||
if (ret)
|
||||
++readers;
|
||||
|
||||
COS_TRACE(("(%p)->lockRead end readers(%d), blocking(%d), pendingWriters(%d), currentWriter(%d), lck_physical(%d)",
|
||||
this, readers, blocking, pendingWriters, currentWriter, cachedLock->lck_physical));
|
||||
|
||||
return fetch(tdbb);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user