Skip to content

Commit

Permalink
Merge pull request #461 from evoskuil/master
Browse files Browse the repository at this point in the history
Leave flush lock and return error on close with fault.
  • Loading branch information
evoskuil authored May 6, 2024
2 parents aa9be58 + 2f87086 commit 2ee84f6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions include/bitcoin/database/impl/store.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,11 @@ code CLASS::close(const event_handler& handler) NOEXCEPT

if (!ec) ec = unload_close(handler);

// unlock errors override ec.
if (!flush_lock_.try_unlock()) ec = error::flush_unlock;
// unlock errors override ec, fault overrides unlock errors.
const auto fault = get_first_error() && !get_error(error::disk_full);
if (!fault && !flush_lock_.try_unlock()) ec = error::flush_unlock;
if (!process_lock_.try_unlock()) ec = error::process_unlock;
if (fault) ec = error::integrity;
transactor_mutex_.unlock();
return ec;
}
Expand Down
2 changes: 1 addition & 1 deletion src/error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ DEFINE_ERROR_T_MESSAGE_MAP(error)
// general
{ success, "success" },
{ unknown_state, "unknown state" },
{ integrity, "integrity failure" },
{ integrity, "store corrupted" },

// memory map
{ open_open, "opening open file" },
Expand Down
2 changes: 1 addition & 1 deletion test/error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ BOOST_AUTO_TEST_CASE(error_t__code__integrity__true_exected_message)
const auto ec = code(value);
BOOST_REQUIRE(ec);
BOOST_REQUIRE(ec == value);
BOOST_REQUIRE_EQUAL(ec.message(), "integrity failure");
BOOST_REQUIRE_EQUAL(ec.message(), "store corrupted");
}

BOOST_AUTO_TEST_CASE(error_t__code__open_open__true_exected_message)
Expand Down

0 comments on commit 2ee84f6

Please sign in to comment.