Skip to content
This repository has been archived by the owner on Sep 22, 2022. It is now read-only.

Commit

Permalink
mdbx: prohibit recursive txn-begin by MDBX_BUSY.
Browse files Browse the repository at this point in the history
Change-Id: I46f5159cec72df9c8aece07fbfb462682499a272
  • Loading branch information
erthink committed Jan 11, 2018
1 parent 18432eb commit 6b55333
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/mdbx.c
Original file line number Diff line number Diff line change
Expand Up @@ -2775,12 +2775,16 @@ int mdbx_txn_begin(MDBX_env *env, MDBX_txn *parent, unsigned flags,
size = env->me_maxdbs * (sizeof(MDBX_db) + sizeof(MDBX_cursor *) + 1);
size += tsize = sizeof(MDBX_ntxn);
} else if (flags & MDBX_RDONLY) {
if (env->me_txn0 && unlikely(env->me_txn0->mt_owner == mdbx_thread_self()))
return MDBX_BUSY;
size = env->me_maxdbs * (sizeof(MDBX_db) + 1);
size += tsize = sizeof(MDBX_txn);
} else {
/* Reuse preallocated write txn. However, do not touch it until
* mdbx_txn_renew0() succeeds, since it currently may be active. */
txn = env->me_txn0;
if (unlikely(txn->mt_owner == mdbx_thread_self()))
return MDBX_BUSY;
goto renew;
}
if (unlikely((txn = calloc(1, size)) == NULL)) {
Expand Down

0 comments on commit 6b55333

Please sign in to comment.