Skip to content

Commit

Permalink
Fix lmdb txn commit code
Browse files Browse the repository at this point in the history
  • Loading branch information
vtnerd committed Jun 4, 2024
1 parent cc73fe7 commit d64a5f7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/lmdb/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,10 @@ namespace lmdb
expect<void> database::commit(write_txn txn) noexcept
{
MONERO_PRECOND(txn != nullptr);
MONERO_LMDB_CHECK(mdb_txn_commit(txn.get()));
txn.release();
const int err = mdb_txn_commit(txn.release());
release_context(ctx);
if (err)
return {lmdb::error(err)};
return success();
}
} // lmdb
9 changes: 6 additions & 3 deletions src/lmdb/database.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,13 @@ namespace lmdb
const auto wrote = f(*(*txn));
if (wrote)
{
MONERO_CHECK(commit(std::move(*txn)));
return wrote;
const auto committed = commit(std::move(*txn));
if (committed)
return wrote;
if (committed != lmdb::error(MDB_MAP_FULL))
return committed.error();
}
if (wrote != lmdb::error(MDB_MAP_FULL))
else if (wrote != lmdb::error(MDB_MAP_FULL))
return wrote;

txn->reset();
Expand Down

0 comments on commit d64a5f7

Please sign in to comment.