mdbx: cleanup after last pull-request.

Cleanup after 4e40af60e74143aedaa8d295f0f33a3c892a1c9b (Merge pull request #20 from rouzier/feature/txn_try).
This commit is contained in:
Leo Yuriev 2017-10-26 20:51:46 +03:00
parent 875d22ff38
commit 17b8e48bf4
6 changed files with 20 additions and 13 deletions

2
mdbx.h
View File

@ -327,7 +327,7 @@ typedef int(MDBX_cmp_func)(const MDBX_val *a, const MDBX_val *b);
/* Store multiple data items in one call. Only for MDBX_DUPFIXED. */
#define MDBX_MULTIPLE 0x80000u
/* Transaction Flags*/
/* Transaction Flags */
/* Do not block when starting a write transaction */
#define MDBX_TRYTXN 0x10000000u

View File

@ -553,8 +553,8 @@ struct MDBX_txn {
/* Transaction Flags */
/* mdbx_txn_begin() flags */
#define MDBX_TXN_BEGIN_FLAGS_PERSISTENT (MDBX_NOMETASYNC | MDBX_NOSYNC | MDBX_RDONLY)
#define MDBX_TXN_BEGIN_FLAGS (MDBX_TXN_BEGIN_FLAGS_PERSISTENT | MDBX_TRYTXN)
#define MDBX_TXN_BEGIN_FLAGS \
(MDBX_NOMETASYNC | MDBX_NOSYNC | MDBX_RDONLY | MDBX_TRYTXN)
#define MDBX_TXN_NOMETASYNC \
MDBX_NOMETASYNC /* don't sync meta for this txn on commit */
#define MDBX_TXN_NOSYNC MDBX_NOSYNC /* don't sync this txn on commit */

View File

@ -2563,7 +2563,8 @@ static int mdbx_txn_renew0(MDBX_txn *txn, unsigned flags) {
} else {
/* Not yet touching txn == env->me_txn0, it may be active */
mdbx_jitter4testing(false);
rc = F_ISSET(flags, MDBX_TRYTXN) ? mdbx_txn_trylock(env) : mdbx_txn_lock(env);
rc = F_ISSET(flags, MDBX_TRYTXN) ? mdbx_txn_trylock(env)
: mdbx_txn_lock(env);
if (unlikely(rc))
return rc;
@ -2665,7 +2666,6 @@ int mdbx_txn_begin(MDBX_env *env, MDBX_txn *parent, unsigned flags,
MDBX_txn **ret) {
MDBX_txn *txn;
MDBX_ntxn *ntxn;
//unsigned pflags;
int rc, size, tsize;
if (unlikely(!env || !ret))
@ -2720,7 +2720,7 @@ int mdbx_txn_begin(MDBX_env *env, MDBX_txn *parent, unsigned flags,
txn->mt_dbxs = env->me_dbxs; /* static */
txn->mt_dbs = (MDBX_db *)((char *)txn + tsize);
txn->mt_dbflags = (uint8_t *)txn + size - env->me_maxdbs;
txn->mt_flags = flags & MDBX_TXN_BEGIN_FLAGS_PERSISTENT;
txn->mt_flags = flags;
txn->mt_env = env;
if (parent) {

View File

@ -20,7 +20,14 @@
#define ACTOR_ID_MAX INT16_MAX
enum actor_testcase { ac_none, ac_hill, ac_deadread, ac_deadwrite, ac_jitter, ac_try };
enum actor_testcase {
ac_none,
ac_hill,
ac_deadread,
ac_deadwrite,
ac_jitter,
ac_try
};
enum actor_status {
as_unknown,

View File

@ -178,17 +178,18 @@ void testcase::db_close() {
}
void testcase::txn_begin(unsigned flags) {
log_trace(">> txn_begin(%s)", flags & MDBX_RDONLY ? "read-only" : "read-write");
log_trace(">> txn_begin(%s)",
flags & MDBX_RDONLY ? "read-only" : "read-write");
assert(!txn_guard);
MDBX_txn *txn = nullptr;
int rc =
mdbx_txn_begin(db_guard.get(), nullptr, flags, &txn);
int rc = mdbx_txn_begin(db_guard.get(), nullptr, flags, &txn);
if (unlikely(rc != MDBX_SUCCESS))
failure_perror("mdbx_txn_begin()", rc);
txn_guard.reset(txn);
log_trace("<< txn_begin(%s)", flags & MDBX_RDONLY ? "read-only" : "read-write");
log_trace("<< txn_begin(%s)",
flags & MDBX_RDONLY ? "read-only" : "read-write");
}
void testcase::txn_end(bool abort) {

View File

@ -15,8 +15,7 @@ bool testcase_try::run() {
MDBX_txn *txn = nullptr;
MDBX_txn *txn2 = nullptr;
int rc =
mdbx_txn_begin(db_guard.get(), nullptr, 0, &txn);
int rc = mdbx_txn_begin(db_guard.get(), nullptr, 0, &txn);
if (unlikely(rc != MDBX_SUCCESS))
failure_perror("mdbx_txn_begin(MDBX_TRYTXN)", rc);
else {