From dd1fc18d107a2cac81acdd8055403bf8d8ca7413 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 11 Jan 2018 21:08:46 +0300 Subject: dbx_mdbx: - Remap() / MDBX_CHECK perversion removed; - mdbx_env_set_geometry() is used to grow file automatically --- plugins/Dbx_mdbx/src/stdafx.h | 57 ++++++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 23 deletions(-) (limited to 'plugins/Dbx_mdbx/src/stdafx.h') diff --git a/plugins/Dbx_mdbx/src/stdafx.h b/plugins/Dbx_mdbx/src/stdafx.h index 25e91a4001..2e50a70e8b 100644 --- a/plugins/Dbx_mdbx/src/stdafx.h +++ b/plugins/Dbx_mdbx/src/stdafx.h @@ -29,6 +29,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include #include +#include #include #include @@ -50,34 +51,46 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # define thread_local __declspec(thread) #endif - class txn_ptr { MDBX_txn *m_txn; public: __forceinline txn_ptr(MDBX_env *pEnv) { - mdbx_txn_begin(pEnv, NULL, 0, &m_txn); + int rc = mdbx_txn_begin(pEnv, NULL, 0, &m_txn); + /* FIXME: throw an exception */ + assert(rc == MDBX_SUCCESS); + UNREFERENCED_PARAMETER(rc); } __forceinline ~txn_ptr() { - if (m_txn) - mdbx_txn_abort(m_txn); + if (m_txn) { + /* FIXME: see https://github.com/leo-yuriev/libfpta/blob/77a7251fde2030165a3916ee68fd86a1374b3dd8/src/common.cxx#L370 */ + abort(); + } } __forceinline operator MDBX_txn*() const { return m_txn; } __forceinline int commit() { - MDBX_txn *tmp = m_txn; + int rc = mdbx_txn_commit(m_txn); + if (rc != MDBX_SUCCESS) { + /* FIXME: throw an exception */ + abort(); + return rc; + } m_txn = nullptr; - return mdbx_txn_commit(tmp); + return MDBX_SUCCESS; } __forceinline void abort() { - mdbx_txn_abort(m_txn); + int rc = mdbx_txn_abort(m_txn); + /* FIXME: throw an exception */ + assert(rc == MDBX_SUCCESS); + UNREFERENCED_PARAMETER(rc); m_txn = NULL; } }; @@ -102,17 +115,21 @@ class txn_ptr_ro public: __forceinline txn_ptr_ro(CMDBX_txn_ro &txn) : m_txn(txn), bNeedReset(!txn.bIsActive), lock(m_txn.cs) { - if (bNeedReset) - { - mdbx_txn_renew(m_txn); + if (bNeedReset) { + int rc = mdbx_txn_renew(m_txn); + /* FIXME: throw an exception */ + assert(rc == MDBX_SUCCESS); + (void)rc; m_txn.bIsActive = true; } } __forceinline ~txn_ptr_ro() { - if (bNeedReset) - { - mdbx_txn_reset(m_txn); + if (bNeedReset) { + int rc = mdbx_txn_reset(m_txn); + /* FIXME: throw an exception */ + assert(rc == MDBX_SUCCESS); + (void)rc; m_txn.bIsActive = false; } } @@ -145,20 +162,14 @@ class cursor_ptr_ro public: __forceinline cursor_ptr_ro(MDBX_cursor *cursor) : m_cursor(cursor) { - mdbx_cursor_renew(mdbx_cursor_txn(m_cursor), m_cursor); + int rc = mdbx_cursor_renew(mdbx_cursor_txn(m_cursor), m_cursor); + /* FIXME: throw an exception */ + assert(rc == MDBX_SUCCESS); + UNREFERENCED_PARAMETER(rc); } __forceinline operator MDBX_cursor*() const { return m_cursor; } }; -#define MDBX_CHECK(A,B) \ - switch (A) { \ - case MDBX_SUCCESS: break; \ - case MDBX_MAP_FULL: continue; \ - default: return (B); } - - - - #include "dbintf.h" #include "resource.h" #include "version.h" -- cgit v1.2.3