aboutsummaryrefslogtreecommitdiff
path: root/src/blockchain_db/berkeleydb
diff options
context:
space:
mode:
Diffstat (limited to 'src/blockchain_db/berkeleydb')
-rw-r--r--src/blockchain_db/berkeleydb/db_bdb.cpp40
-rw-r--r--src/blockchain_db/berkeleydb/db_bdb.h4
2 files changed, 44 insertions, 0 deletions
diff --git a/src/blockchain_db/berkeleydb/db_bdb.cpp b/src/blockchain_db/berkeleydb/db_bdb.cpp
index f93d6e988..ce355ccde 100644
--- a/src/blockchain_db/berkeleydb/db_bdb.cpp
+++ b/src/blockchain_db/berkeleydb/db_bdb.cpp
@@ -964,7 +964,41 @@ void BlockchainBDB::close()
// FIXME: not yet thread safe!!! Use with care.
m_open = false;
+
+ // DB_FORCESYNC is only available on newer version of libdb.
+ // The libdb doc says using the DB_FORCESYNC flag to DB_ENV->close
+ // is "similar to calling the DB->close(0) method to close each
+ // database handle". So this is what we do here as a fallback.
+#ifdef DB_FORCESYNC
m_env->close(DB_FORCESYNC);
+#else
+ m_blocks->close(0);
+ m_block_heights->close(0);
+ m_block_hashes->close(0);
+ m_block_timestamps->close(0);
+ m_block_sizes->close(0);
+ m_block_diffs->close(0);
+ m_block_coins->close(0);
+
+ m_txs->close(0);
+ m_tx_unlocks->close(0);
+ m_tx_heights->close(0);
+ m_tx_outputs->close(0);
+
+ m_output_txs->close(0);
+ m_output_indices->close(0);
+ m_output_amounts->close(0);
+ m_output_keys->close(0);
+
+ m_spent_keys->close(0);
+
+ m_hf_starting_heights->close(0);
+ m_hf_versions->close(0);
+
+ m_properties->close(0);
+
+ m_env->close(0);
+#endif
}
void BlockchainBDB::sync()
@@ -2123,4 +2157,10 @@ void BlockchainBDB::checkpoint_worker() const
LOG_PRINT_L0("Leaving BDB checkpoint thread.")
}
+void BlockchainBDB::fixup()
+{
+ // Always call parent as well
+ BlockchainDB::fixup();
+}
+
} // namespace cryptonote
diff --git a/src/blockchain_db/berkeleydb/db_bdb.h b/src/blockchain_db/berkeleydb/db_bdb.h
index d05abea25..c79d8b26f 100644
--- a/src/blockchain_db/berkeleydb/db_bdb.h
+++ b/src/blockchain_db/berkeleydb/db_bdb.h
@@ -405,6 +405,10 @@ private:
uint64_t get_output_global_index(const uint64_t& amount, const uint64_t& index);
void checkpoint_worker() const;
void check_open() const;
+ //
+ // fix up anything that may be wrong due to past bugs
+ virtual void fixup();
+
bool m_run_checkpoint;
std::unique_ptr<boost::thread> m_checkpoint_thread;
typedef bdb_safe_buffer<void *> bdb_safe_buffer_t;