From eae6a13cd510ef0949868842fbd2b93654b560d4 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 22 Jun 2018 11:00:03 +0300 Subject: DebugBreak() removed from unsuccessful transaction opening --- plugins/Dbx_mdbx/src/dbutils.cpp | 34 ++++++++++++++++++++++++++++++++++ plugins/Dbx_mdbx/src/stdafx.h | 15 +++------------ 2 files changed, 37 insertions(+), 12 deletions(-) (limited to 'plugins/Dbx_mdbx/src') diff --git a/plugins/Dbx_mdbx/src/dbutils.cpp b/plugins/Dbx_mdbx/src/dbutils.cpp index 147b43ef30..e3d125d302 100644 --- a/plugins/Dbx_mdbx/src/dbutils.cpp +++ b/plugins/Dbx_mdbx/src/dbutils.cpp @@ -45,3 +45,37 @@ int DBSettingKey::Compare(const MDBX_val *ax, const MDBX_val *bx) CMP_UINT(a->dwModuleId, b->dwModuleId); return strcmp(a->szSettingName, b->szSettingName); } + +///////////////////////////////////////////////////////////////////////////////////////// + +txn_ptr_ro::txn_ptr_ro(CMDBX_txn_ro &_txn) : + txn(_txn), + lock(txn.cs) +{ + for (int nRetries = 0; nRetries < 5; nRetries++) { + int rc = mdbx_txn_renew(txn); + if (rc == MDBX_SUCCESS) + break; + + #ifdef _DEBUG + DebugBreak(); + #endif + Netlib_Logf(nullptr, "txn_ptr_ro::txn_ptr_ro failed with error=%d, retrying...", rc); + Sleep(0); + } +} + +txn_ptr_ro::~txn_ptr_ro() +{ + for (int nRetries = 0; nRetries < 5; nRetries++) { + int rc = mdbx_txn_reset(txn); + if (rc == MDBX_SUCCESS) + break; + + #ifdef _DEBUG + DebugBreak(); + #endif + Netlib_Logf(nullptr, "txn_ptr_ro::~txn_ptr_ro failed with error=%d, retrying...", rc); + Sleep(0); + } +} diff --git a/plugins/Dbx_mdbx/src/stdafx.h b/plugins/Dbx_mdbx/src/stdafx.h index cbb50765ab..49f182f5cf 100644 --- a/plugins/Dbx_mdbx/src/stdafx.h +++ b/plugins/Dbx_mdbx/src/stdafx.h @@ -109,18 +109,9 @@ class txn_ptr_ro mir_cslock lock; public: - __forceinline txn_ptr_ro(CMDBX_txn_ro &_txn) : txn(_txn), lock(txn.cs) - { - int rc = mdbx_txn_renew(txn); - if (rc != MDBX_SUCCESS) - DebugBreak(); - } - __forceinline ~txn_ptr_ro() - { - int rc = mdbx_txn_reset(txn); - if (rc != MDBX_SUCCESS) - DebugBreak(); - } + txn_ptr_ro(CMDBX_txn_ro &_txn); + ~txn_ptr_ro(); + __forceinline operator MDBX_txn*() const { return txn; } }; -- cgit v1.2.3