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

Implement wait with timeout for page buffer's latches.

Note, engine passes timeout as negative seconds, while sync objects works with positive milliseconds.
This commit is contained in:
hvlad 2013-06-16 21:41:35 +00:00
parent 030dcd999d
commit 0b5815507c
2 changed files with 9 additions and 9 deletions

View File

@ -3641,7 +3641,7 @@ static LatchState latch_buffer(thread_db* tdbb, Sync &bcbSync, BufferDesc *bdb,
if (waitPending)
{
//--bdb->bdb_use_count;
if (wait <= 0) {
if (wait == 0) {
return lsTimeout; // go out
}
@ -3649,11 +3649,7 @@ static LatchState latch_buffer(thread_db* tdbb, Sync &bcbSync, BufferDesc *bdb,
}
else
{
bool latchOk = true;
if (wait <= 0)
latchOk = bdb->addRefConditional(tdbb, syncType);
else
bdb->addRef(tdbb, syncType);
const bool latchOk = bdb->addRef(tdbb, syncType, wait);
//--bdb->bdb_use_count;
@ -5211,9 +5207,12 @@ void BufferControl::destroy(BufferControl* bcb)
}
void BufferDesc::addRef(thread_db* tdbb, SyncType syncType)
bool BufferDesc::addRef(thread_db* tdbb, SyncType syncType, int wait)
{
bdb_syncPage.lock(NULL, syncType, FB_FUNCTION);
if (wait == 1)
bdb_syncPage.lock(NULL, syncType, FB_FUNCTION);
else if (!bdb_syncPage.lock(NULL, syncType, FB_FUNCTION, -wait * 1000))
return false;
++bdb_use_count;
@ -5224,6 +5223,7 @@ void BufferDesc::addRef(thread_db* tdbb, SyncType syncType)
}
tdbb->registerBdb(this);
return true;
}

View File

@ -198,7 +198,7 @@ public:
bdb_prec_walk_mark = 0;
}
void addRef(thread_db* tdbb, Firebird::SyncType syncType);
bool addRef(thread_db* tdbb, Firebird::SyncType syncType, int wait = 1);
bool addRefConditional(thread_db* tdbb, Firebird::SyncType syncType);
void downgrade(Firebird::SyncType syncType);
void release(thread_db* tdbb, bool repost);