summaryrefslogtreecommitdiff
path: root/plugins/Dbx_mdbx/src
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Dbx_mdbx/src')
-rw-r--r--plugins/Dbx_mdbx/src/dbutils.cpp34
-rw-r--r--plugins/Dbx_mdbx/src/stdafx.h15
2 files changed, 37 insertions, 12 deletions
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; }
};