diff options
author | Howard Chu <hyc@symas.com> | 2017-02-18 21:57:06 +0000 |
---|---|---|
committer | Howard Chu <hyc@symas.com> | 2017-02-18 22:22:24 +0000 |
commit | bed2d9f231cbe30c6935e267eee9f272c852809f (patch) | |
tree | 3ce627534238d511951203f592e729878fc2b7c6 | |
parent | Handle map resizes from other processes (diff) | |
download | monero-bed2d9f231cbe30c6935e267eee9f272c852809f.tar.xz |
Get rid of directory lock
We don't need it any more. Fixes issue #1633
-rw-r--r-- | src/cryptonote_core/cryptonote_core.cpp | 40 | ||||
-rw-r--r-- | src/cryptonote_core/cryptonote_core.h | 18 |
2 files changed, 0 insertions, 58 deletions
diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp index b940dba3c..239ef5d84 100644 --- a/src/cryptonote_core/cryptonote_core.cpp +++ b/src/cryptonote_core/cryptonote_core.cpp @@ -219,40 +219,6 @@ namespace cryptonote return m_blockchain_storage.get_alternative_blocks_count(); } //----------------------------------------------------------------------------------------------- - bool core::lock_db_directory(const boost::filesystem::path &path) - { - // boost doesn't like locking directories... - const boost::filesystem::path lock_path = path / ".daemon_lock"; - - try - { - // ensure the file exists - std::ofstream(lock_path.string(), std::ios::out).close(); - - db_lock = boost::interprocess::file_lock(lock_path.string().c_str()); - LOG_PRINT_L1("Locking " << lock_path.string()); - if (!db_lock.try_lock()) - { - LOG_ERROR("Failed to lock " << lock_path.string()); - return false; - } - return true; - } - catch (const std::exception &e) - { - LOG_ERROR("Error trying to lock " << lock_path.string() << ": " << e.what()); - return false; - } - } - //----------------------------------------------------------------------------------------------- - bool core::unlock_db_directory() - { - db_lock.unlock(); - db_lock = boost::interprocess::file_lock(); - LOG_PRINT_L1("Blockchain directory successfully unlocked"); - return true; - } - //----------------------------------------------------------------------------------------------- bool core::init(const boost::program_options::variables_map& vm, const cryptonote::test_options *test_options) { start_time = std::time(nullptr); @@ -284,11 +250,6 @@ namespace cryptonote // make sure the data directory exists, and try to lock it CHECK_AND_ASSERT_MES (boost::filesystem::exists(folder) || boost::filesystem::create_directories(folder), false, std::string("Failed to create directory ").append(folder.string()).c_str()); - if (!lock_db_directory (folder)) - { - LOG_ERROR ("Failed to lock " << folder); - return false; - } // check for blockchain.bin try @@ -440,7 +401,6 @@ namespace cryptonote m_miner.stop(); m_mempool.deinit(); m_blockchain_storage.deinit(); - unlock_db_directory(); return true; } //----------------------------------------------------------------------------------------------- diff --git a/src/cryptonote_core/cryptonote_core.h b/src/cryptonote_core/cryptonote_core.h index fe1d11916..1463c2feb 100644 --- a/src/cryptonote_core/cryptonote_core.h +++ b/src/cryptonote_core/cryptonote_core.h @@ -763,24 +763,6 @@ namespace cryptonote */ bool relay_txpool_transactions(); - /** - * @brief locks a file in the BlockchainDB directory - * - * @param path the directory in which to place the file - * - * @return true if lock acquired successfully, otherwise false - */ - bool lock_db_directory(const boost::filesystem::path &path); - - /** - * @brief unlocks the db directory - * - * @note see lock_db_directory() - * - * @return true - */ - bool unlock_db_directory(); - bool m_test_drop_download = true; //!< whether or not to drop incoming blocks (for testing) uint64_t m_test_drop_download_height = 0; //!< height under which to drop incoming blocks, if doing so |