2024-05-19 22:07:58 +03:00
|
|
|
/// \author Леонид Юрьев aka Leonid Yuriev <leo@yuriev.ru> \date 2015-2024
|
|
|
|
/// \copyright SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2022-11-08 16:17:14 +03:00
|
|
|
#include "test.h++"
|
2017-10-25 20:56:12 -04:00
|
|
|
|
2021-03-15 20:52:18 +03:00
|
|
|
class testcase_try : public testcase {
|
|
|
|
public:
|
|
|
|
testcase_try(const actor_config &config, const mdbx_pid_t pid)
|
|
|
|
: testcase(config, pid) {}
|
|
|
|
bool run() override;
|
|
|
|
};
|
|
|
|
REGISTER_TESTCASE(try);
|
|
|
|
|
2017-10-25 20:56:12 -04:00
|
|
|
bool testcase_try::run() {
|
|
|
|
db_open();
|
|
|
|
assert(!txn_guard);
|
|
|
|
|
|
|
|
MDBX_txn *txn = nullptr;
|
|
|
|
MDBX_txn *txn2 = nullptr;
|
2020-08-04 01:06:01 +03:00
|
|
|
int rc = mdbx_txn_begin(db_guard.get(), nullptr, MDBX_TXN_READWRITE, &txn);
|
2017-10-25 20:56:12 -04:00
|
|
|
if (unlikely(rc != MDBX_SUCCESS))
|
2020-08-02 20:52:36 +03:00
|
|
|
failure_perror("mdbx_txn_begin(MDBX_TXN_TRY)", rc);
|
2017-10-25 20:56:12 -04:00
|
|
|
else {
|
2020-08-02 20:52:36 +03:00
|
|
|
rc = mdbx_txn_begin(db_guard.get(), nullptr, MDBX_TXN_TRY, &txn2);
|
2017-10-25 20:56:12 -04:00
|
|
|
if (unlikely(rc != MDBX_BUSY))
|
2020-08-02 20:52:36 +03:00
|
|
|
failure_perror("mdbx_txn_begin(MDBX_TXN_TRY)", rc);
|
2017-10-25 20:56:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
txn_guard.reset(txn);
|
|
|
|
return true;
|
|
|
|
}
|