summaryrefslogtreecommitdiff
path: root/plugins/Dbx_mdbx
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-01-24 17:51:01 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-01-24 17:51:01 +0300
commitc4722415c258aca682c7a817ead9e7143a23ee44 (patch)
tree57f36ec0b919d6c23b7b64291901861499cd4504 /plugins/Dbx_mdbx
parent6121a75e201ed9c4296838bdfae424972be44f40 (diff)
merge with libmdbx
Diffstat (limited to 'plugins/Dbx_mdbx')
-rw-r--r--plugins/Dbx_mdbx/src/libmdbx/src/mdbx.c14
-rw-r--r--plugins/Dbx_mdbx/src/stdafx.h10
2 files changed, 10 insertions, 14 deletions
diff --git a/plugins/Dbx_mdbx/src/libmdbx/src/mdbx.c b/plugins/Dbx_mdbx/src/libmdbx/src/mdbx.c
index 0d0a9cd0c9..a8e0500326 100644
--- a/plugins/Dbx_mdbx/src/libmdbx/src/mdbx.c
+++ b/plugins/Dbx_mdbx/src/libmdbx/src/mdbx.c
@@ -2713,7 +2713,7 @@ int mdbx_txn_renew(MDBX_txn *txn) {
if (unlikely(txn->mt_signature != MDBX_MT_SIGNATURE))
return MDBX_EBADSIGN;
- if (unlikely(!F_ISSET(txn->mt_flags, MDBX_TXN_RDONLY | MDBX_TXN_FINISHED)))
+ if (unlikely((txn->mt_flags & MDBX_TXN_RDONLY) == 0))
return MDBX_EINVAL;
if (unlikely(txn->mt_owner != 0))
@@ -2936,7 +2936,7 @@ static int mdbx_txn_end(MDBX_txn *txn, unsigned mode) {
}
mdbx_coherent_barrier();
txn->mt_numdbs = 0; /* prevent further DBI activity */
- txn->mt_flags |= MDBX_TXN_FINISHED;
+ txn->mt_flags = MDBX_TXN_RDONLY | MDBX_TXN_FINISHED;
txn->mt_owner = 0;
} else if (!F_ISSET(txn->mt_flags, MDBX_TXN_FINISHED)) {
pgno_t *pghead = env->me_reclaimed_pglist;
@@ -2956,6 +2956,7 @@ static int mdbx_txn_end(MDBX_txn *txn, unsigned mode) {
}
txn->mt_numdbs = 0;
txn->mt_flags = MDBX_TXN_FINISHED;
+ txn->mt_owner = 0;
if (!txn->mt_parent) {
mdbx_pnl_shrink(&txn->mt_befree_pages);
@@ -2965,8 +2966,6 @@ static int mdbx_txn_end(MDBX_txn *txn, unsigned mode) {
env->me_last_reclaimed = 0;
env->me_txn = NULL;
- txn->mt_owner = 0;
- txn->mt_signature = 0;
mode = 0; /* txn == env->me_txn0, do not free() it */
/* The writer mutex was locked in mdbx_txn_begin. */
@@ -2983,9 +2982,9 @@ static int mdbx_txn_end(MDBX_txn *txn, unsigned mode) {
mdbx_pnl_free(pghead);
}
+ mdbx_assert(env, txn->mt_owner == 0);
if (mode & MDBX_END_FREE) {
mdbx_ensure(env, txn != env->me_txn0);
- txn->mt_owner = 0;
txn->mt_signature = 0;
free(txn);
}
@@ -3023,8 +3022,7 @@ int mdbx_txn_abort(MDBX_txn *txn) {
if (unlikely(txn->mt_signature != MDBX_MT_SIGNATURE))
return MDBX_EBADSIGN;
- if (unlikely(txn->mt_owner !=
- ((txn->mt_flags & MDBX_TXN_FINISHED) ? 0 : mdbx_thread_self())))
+ if (unlikely(txn->mt_owner && txn->mt_owner != mdbx_thread_self()))
return MDBX_THREAD_MISMATCH;
if (F_ISSET(txn->mt_flags, MDBX_TXN_RDONLY))
@@ -10127,7 +10125,7 @@ static MDBX_cmp_func *mdbx_default_keycmp(unsigned flags) {
static MDBX_cmp_func *mdbx_default_datacmp(unsigned flags) {
return !(flags & MDBX_DUPSORT)
- ? mdbx_cmp_memn
+ ? 0
: ((flags & MDBX_INTEGERDUP)
? mdbx_cmp_int_ua
: ((flags & MDBX_REVERSEDUP) ? mdbx_cmp_memnr
diff --git a/plugins/Dbx_mdbx/src/stdafx.h b/plugins/Dbx_mdbx/src/stdafx.h
index 428860127c..15acf9a137 100644
--- a/plugins/Dbx_mdbx/src/stdafx.h
+++ b/plugins/Dbx_mdbx/src/stdafx.h
@@ -113,16 +113,14 @@ public:
__forceinline txn_ptr_ro(CMDBX_txn_ro &_txn) : txn(_txn), lock(txn.cs)
{
int rc = mdbx_txn_renew(txn);
- /* FIXME: throw an exception */
- _ASSERT(rc == MDBX_SUCCESS);
- UNREFERENCED_PARAMETER(rc);
+ if (rc != MDBX_SUCCESS)
+ DebugBreak();
}
__forceinline ~txn_ptr_ro()
{
int rc = mdbx_txn_reset(txn);
- /* FIXME: throw an exception */
- _ASSERT(rc == MDBX_SUCCESS);
- UNREFERENCED_PARAMETER(rc);
+ if (rc != MDBX_SUCCESS)
+ DebugBreak();
}
__forceinline operator MDBX_txn*() const { return txn; }
};