Skip to content

Commit

Permalink
Using compiler conditional to avoid referencing newer flag, #267, #273
Browse files Browse the repository at this point in the history
  • Loading branch information
kriszyp committed Feb 21, 2024
1 parent df95629 commit 03c945d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,26 +123,32 @@ int WriteWorker::WaitForCallbacks(MDB_txn** txn, bool allowCommit, uint32_t* tar
uint64_t start;
unsigned int envFlags;
mdb_env_get_flags(env, &envFlags);
#ifdef MDB_TRACK_METRICS
if (envFlags & MDB_TRACK_METRICS)
start = get_time64();
#endif
if (target) {
uint64_t delay = 1;
do {
cond_timedwait(envForTxn->writingCond, envForTxn->writingLock, delay);
delay = delay << 1ll;
if ((*target & 0xf) || (allowCommit && finishedProgress)) {
// we are in position to continue writing or commit, so forward progress can be made without interrupting yet
#ifdef MDB_TRACK_METRICS
if (envFlags & MDB_TRACK_METRICS)
envForTxn->timeTxnWaiting += get_time64() - start;
#endif
interruptionStatus = 0;
return 0;
}
} while(interruptionStatus != INTERRUPT_BATCH);
} else {
pthread_cond_wait(envForTxn->writingCond, envForTxn->writingLock);
}
#ifdef MDB_TRACK_METRICS
if (envFlags & MDB_TRACK_METRICS)
envForTxn->timeTxnWaiting += get_time64() - start;
#endif
if (interruptionStatus == INTERRUPT_BATCH) { // interrupted by JS code that wants to run a synchronous transaction
interruptionStatus = RESTART_WORKER_TXN;
rc = mdb_txn_commit(*txn);
Expand Down

0 comments on commit 03c945d

Please sign in to comment.