From 2f87086cabe89416f767f03a1b5916b690dffb22 Mon Sep 17 00:00:00 2001 From: evoskuil Date: Sun, 5 May 2024 21:57:32 -0400 Subject: [PATCH] Leave flush lock and return error on close with fault. --- include/bitcoin/database/impl/store.ipp | 6 ++++-- src/error.cpp | 2 +- test/error.cpp | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/include/bitcoin/database/impl/store.ipp b/include/bitcoin/database/impl/store.ipp index 878557ab..df0fb5bc 100644 --- a/include/bitcoin/database/impl/store.ipp +++ b/include/bitcoin/database/impl/store.ipp @@ -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; } diff --git a/src/error.cpp b/src/error.cpp index dc378739..e0c934f4 100644 --- a/src/error.cpp +++ b/src/error.cpp @@ -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" }, diff --git a/test/error.cpp b/test/error.cpp index 52c76b93..98ee7761 100644 --- a/test/error.cpp +++ b/test/error.cpp @@ -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)