mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-10 21:34:13 +08:00
mdbx: Merge branch 'master' into stable/0.1
This commit is contained in:
commit
e1e17fd6a4
@ -1,4 +1,4 @@
|
|||||||
version: 0.1.4.{build}
|
version: 0.1.5.{build}
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
matrix:
|
matrix:
|
||||||
|
13
src/bits.h
13
src/bits.h
@ -23,11 +23,6 @@
|
|||||||
# undef NDEBUG
|
# undef NDEBUG
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Features under development */
|
|
||||||
#ifndef MDBX_DEVEL
|
|
||||||
# define MDBX_DEVEL 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
/* Should be defined before any includes */
|
/* Should be defined before any includes */
|
||||||
@ -144,9 +139,9 @@
|
|||||||
#define MDBX_MAGIC UINT64_C(/* 56-bit prime */ 0x59659DBDEF4C11)
|
#define MDBX_MAGIC UINT64_C(/* 56-bit prime */ 0x59659DBDEF4C11)
|
||||||
|
|
||||||
/* The version number for a database's datafile format. */
|
/* The version number for a database's datafile format. */
|
||||||
#define MDBX_DATA_VERSION ((MDBX_DEVEL) ? 255 : 2)
|
#define MDBX_DATA_VERSION 2
|
||||||
/* The version number for a database's lockfile format. */
|
/* The version number for a database's lockfile format. */
|
||||||
#define MDBX_LOCK_VERSION ((MDBX_DEVEL) ? 255 : 2)
|
#define MDBX_LOCK_VERSION 2
|
||||||
|
|
||||||
/* handle for the DB used to track free pages. */
|
/* handle for the DB used to track free pages. */
|
||||||
#define FREE_DBI 0
|
#define FREE_DBI 0
|
||||||
@ -171,9 +166,7 @@ typedef uint32_t pgno_t;
|
|||||||
/* A transaction ID. */
|
/* A transaction ID. */
|
||||||
typedef uint64_t txnid_t;
|
typedef uint64_t txnid_t;
|
||||||
#define PRIaTXN PRIi64
|
#define PRIaTXN PRIi64
|
||||||
#if MDBX_DEVEL
|
#if MDBX_DEBUG
|
||||||
#define MIN_TXNID (UINT64_MAX - UINT32_MAX)
|
|
||||||
#elif MDBX_DEBUG
|
|
||||||
#define MIN_TXNID UINT64_C(0x100000000)
|
#define MIN_TXNID UINT64_C(0x100000000)
|
||||||
#else
|
#else
|
||||||
#define MIN_TXNID UINT64_C(1)
|
#define MIN_TXNID UINT64_C(1)
|
||||||
|
35
src/mdbx.c
35
src/mdbx.c
@ -2711,7 +2711,7 @@ fail:
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mdbx_env_sync(MDBX_env *env, int force) {
|
static int mdbx_env_sync_ex(MDBX_env *env, int force, int nonblock) {
|
||||||
if (unlikely(!env))
|
if (unlikely(!env))
|
||||||
return MDBX_EINVAL;
|
return MDBX_EINVAL;
|
||||||
|
|
||||||
@ -2729,7 +2729,7 @@ int mdbx_env_sync(MDBX_env *env, int force) {
|
|||||||
(!env->me_txn0 || env->me_txn0->mt_owner != mdbx_thread_self());
|
(!env->me_txn0 || env->me_txn0->mt_owner != mdbx_thread_self());
|
||||||
|
|
||||||
if (outside_txn) {
|
if (outside_txn) {
|
||||||
int rc = mdbx_txn_lock(env, false);
|
int rc = mdbx_txn_lock(env, nonblock);
|
||||||
if (unlikely(rc != MDBX_SUCCESS))
|
if (unlikely(rc != MDBX_SUCCESS))
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@ -2758,7 +2758,7 @@ int mdbx_env_sync(MDBX_env *env, int force) {
|
|||||||
if (unlikely(rc != MDBX_SUCCESS))
|
if (unlikely(rc != MDBX_SUCCESS))
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
rc = mdbx_txn_lock(env, false);
|
rc = mdbx_txn_lock(env, nonblock);
|
||||||
if (unlikely(rc != MDBX_SUCCESS))
|
if (unlikely(rc != MDBX_SUCCESS))
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
@ -2785,6 +2785,10 @@ int mdbx_env_sync(MDBX_env *env, int force) {
|
|||||||
return MDBX_SUCCESS;
|
return MDBX_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int mdbx_env_sync(MDBX_env *env, int force) {
|
||||||
|
return mdbx_env_sync_ex(env, force, false);
|
||||||
|
}
|
||||||
|
|
||||||
/* Back up parent txn's cursors, then grab the originals for tracking */
|
/* Back up parent txn's cursors, then grab the originals for tracking */
|
||||||
static int mdbx_cursor_shadow(MDBX_txn *src, MDBX_txn *dst) {
|
static int mdbx_cursor_shadow(MDBX_txn *src, MDBX_txn *dst) {
|
||||||
MDBX_cursor *mc, *bk;
|
MDBX_cursor *mc, *bk;
|
||||||
@ -4338,8 +4342,8 @@ static int __cold mdbx_read_header(MDBX_env *env, MDBX_meta *meta,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (page.mp_meta.mm_magic_and_version != MDBX_DATA_MAGIC) {
|
if (page.mp_meta.mm_magic_and_version != MDBX_DATA_MAGIC) {
|
||||||
mdbx_error("meta[%u] has invalid magic/version MDBX_DEVEL=%d",
|
mdbx_error("meta[%u] has invalid magic/version %" PRIx64, meta_number,
|
||||||
meta_number, MDBX_DEVEL);
|
page.mp_meta.mm_magic_and_version);
|
||||||
return ((page.mp_meta.mm_magic_and_version >> 8) != MDBX_MAGIC)
|
return ((page.mp_meta.mm_magic_and_version >> 8) != MDBX_MAGIC)
|
||||||
? MDBX_INVALID
|
? MDBX_INVALID
|
||||||
: MDBX_VERSION_MISMATCH;
|
: MDBX_VERSION_MISMATCH;
|
||||||
@ -5940,8 +5944,21 @@ int __cold mdbx_env_close_ex(MDBX_env *env, int dont_sync) {
|
|||||||
if (env->me_txn0 && env->me_txn0->mt_owner &&
|
if (env->me_txn0 && env->me_txn0->mt_owner &&
|
||||||
env->me_txn0->mt_owner != mdbx_thread_self())
|
env->me_txn0->mt_owner != mdbx_thread_self())
|
||||||
return MDBX_BUSY;
|
return MDBX_BUSY;
|
||||||
if (!dont_sync)
|
if (!dont_sync) {
|
||||||
rc = mdbx_env_sync(env, true);
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
|
/* On windows, without blocking is impossible to determine whether another
|
||||||
|
* process is running a writing transaction or not.
|
||||||
|
* Because in the "owner died" condition kernel don't release
|
||||||
|
* file lock immediately. */
|
||||||
|
rc = mdbx_env_sync_ex(env, true, false);
|
||||||
|
#else
|
||||||
|
rc = mdbx_env_sync_ex(env, true, true);
|
||||||
|
rc = (rc == MDBX_BUSY || rc == EAGAIN || rc == EACCES || rc == EBUSY ||
|
||||||
|
rc == EWOULDBLOCK)
|
||||||
|
? MDBX_SUCCESS
|
||||||
|
: rc;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VALGRIND_DESTROY_MEMPOOL(env);
|
VALGRIND_DESTROY_MEMPOOL(env);
|
||||||
@ -5968,7 +5985,7 @@ int __cold mdbx_env_close_ex(MDBX_env *env, int dont_sync) {
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mdbx_env_close(MDBX_env *env) { return mdbx_env_close_ex(env, 0); }
|
int mdbx_env_close(MDBX_env *env) { return mdbx_env_close_ex(env, false); }
|
||||||
|
|
||||||
/* Compare two items pointing at aligned unsigned int's. */
|
/* Compare two items pointing at aligned unsigned int's. */
|
||||||
static int __hot mdbx_cmp_int_ai(const MDBX_val *a, const MDBX_val *b) {
|
static int __hot mdbx_cmp_int_ai(const MDBX_val *a, const MDBX_val *b) {
|
||||||
@ -11473,7 +11490,7 @@ int __cold mdbx_env_set_syncbytes(MDBX_env *env, size_t bytes) {
|
|||||||
return MDBX_EBADSIGN;
|
return MDBX_EBADSIGN;
|
||||||
|
|
||||||
env->me_sync_threshold = bytes;
|
env->me_sync_threshold = bytes;
|
||||||
return env->me_map ? mdbx_env_sync(env, 0) : MDBX_SUCCESS;
|
return env->me_map ? mdbx_env_sync(env, false) : MDBX_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int __cold mdbx_env_set_oomfunc(MDBX_env *env, MDBX_oom_func *oomfunc) {
|
int __cold mdbx_env_set_oomfunc(MDBX_env *env, MDBX_oom_func *oomfunc) {
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
#error "API version mismatch!"
|
#error "API version mismatch!"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MDBX_VERSION_RELEASE 4
|
#define MDBX_VERSION_RELEASE 5
|
||||||
#define MDBX_VERSION_REVISION 1
|
#define MDBX_VERSION_REVISION 1
|
||||||
|
|
||||||
/*LIBMDBX_EXPORTS*/ const mdbx_version_info mdbx_version = {
|
/*LIBMDBX_EXPORTS*/ const mdbx_version_info mdbx_version = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user