diff --git a/src/ProjectFileIO.cpp b/src/ProjectFileIO.cpp index bd15b9b9f..f74787bbe 100644 --- a/src/ProjectFileIO.cpp +++ b/src/ProjectFileIO.cpp @@ -311,11 +311,8 @@ void ProjectFileIO::CheckpointThread() } // Capture the number of pages that need checkpointing and reset - mCheckpointCurrentPages = mCheckpointWaitingPages; + mCheckpointCurrentPages.store( mCheckpointWaitingPages ); mCheckpointWaitingPages = 0; - - // Lock out others while the checkpoint is running - mCheckpointActive.lock(); } // Open another connection to the DB to prevent blocking the main thread. @@ -334,10 +331,10 @@ void ProjectFileIO::CheckpointThread() // Reset mCheckpointCurrentPages = 0; - - // Checkpoint is complete - mCheckpointActive.unlock(); } + else + // Gotta close it anyway! + sqlite3_close( db ); } return; @@ -348,7 +345,7 @@ int ProjectFileIO::CheckpointHook(void *data, sqlite3 *db, const char *schema, i // Get access to our object ProjectFileIO *that = static_cast(data); - // Qeuue the database pointer for our checkpoint thread to process + // Queue the database pointer for our checkpoint thread to process std::lock_guard guard(that->mCheckpointMutex); that->mCheckpointWaitingPages = pages; that->mCheckpointCondition.notify_one(); diff --git a/src/ProjectFileIO.h b/src/ProjectFileIO.h index 767ff49bc..83f5e34cb 100644 --- a/src/ProjectFileIO.h +++ b/src/ProjectFileIO.h @@ -229,11 +229,9 @@ private: std::thread mCheckpointThread; std::condition_variable mCheckpointCondition; std::mutex mCheckpointMutex; - std::mutex mCheckpointActive; - std::mutex mCheckpointClose; - std::atomic_bool mCheckpointStop; - uint64_t mCheckpointWaitingPages; - uint64_t mCheckpointCurrentPages; + std::atomic_bool mCheckpointStop{ false }; + std::atomic< std::uint64_t > mCheckpointWaitingPages{ 0 }; + std::atomic< std::uint64_t > mCheckpointCurrentPages{ 0 }; friend SqliteSampleBlock; friend AutoCommitTransaction;