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:
parent
030dcd999d
commit
0b5815507c
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user