From 17b8e48bf49110e65b4913f82d6a8e0c9609295f Mon Sep 17 00:00:00 2001 From: Leo Yuriev Date: Thu, 26 Oct 2017 20:51:46 +0300 Subject: [PATCH] mdbx: cleanup after last pull-request. Cleanup after 4e40af60e74143aedaa8d295f0f33a3c892a1c9b (Merge pull request #20 from rouzier/feature/txn_try). --- mdbx.h | 2 +- src/bits.h | 4 ++-- src/mdbx.c | 6 +++--- test/config.h | 9 ++++++++- test/test.cc | 9 +++++---- test/try.cc | 3 +-- 6 files changed, 20 insertions(+), 13 deletions(-) diff --git a/mdbx.h b/mdbx.h index d8453d05..421d833b 100644 --- a/mdbx.h +++ b/mdbx.h @@ -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 diff --git a/src/bits.h b/src/bits.h index 88a8032d..aeb88086 100644 --- a/src/bits.h +++ b/src/bits.h @@ -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 */ diff --git a/src/mdbx.c b/src/mdbx.c index a74c9376..7e480ce3 100644 --- a/src/mdbx.c +++ b/src/mdbx.c @@ -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) { diff --git a/test/config.h b/test/config.h index aecfcd3e..c2ac1389 100644 --- a/test/config.h +++ b/test/config.h @@ -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, diff --git a/test/test.cc b/test/test.cc index 6bb17735..e8df1eaf 100644 --- a/test/test.cc +++ b/test/test.cc @@ -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) { diff --git a/test/try.cc b/test/try.cc index 4071c24c..1deae71d 100644 --- a/test/try.cc +++ b/test/try.cc @@ -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 {