diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c453c7e..743d7dfd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ cmake_minimum_required(VERSION 3.2) # There is no C per se in WDT but if you use CXX only here many checks fail # Version is Major.Minor.YYMMDDX for up to 10 releases per day # Minor currently is also the protocol version - has to match with Protocol.cpp -project("WDT" LANGUAGES C CXX VERSION 1.19.1509160) +project("WDT" LANGUAGES C CXX VERSION 1.19.1509200) # On MacOS this requires the latest (master) CMake (and/or CMake 3.1.1/3.2) set(CMAKE_CXX_STANDARD 11) diff --git a/DirectorySourceQueue.cpp b/DirectorySourceQueue.cpp index 7a224fe9..a6bc660b 100644 --- a/DirectorySourceQueue.cpp +++ b/DirectorySourceQueue.cpp @@ -128,6 +128,14 @@ bool DirectorySourceQueue::setRootDir(const string &newRootDir) { return true; } +void DirectorySourceQueue::clearSourceQueue() { + // clear current content of the queue. For some reason, priority_queue does + // not have a clear method + while (!sourceQueue_.empty()) { + sourceQueue_.pop(); + } +} + void DirectorySourceQueue::setPreviouslyReceivedChunks( std::vector &previouslyTransferredChunks) { std::unique_lock lock(mutex_); @@ -142,11 +150,7 @@ void DirectorySourceQueue::setPreviouslyReceivedChunks( previouslyTransferredChunks_.insert( std::make_pair(chunkInfo.getFileName(), std::move(chunkInfo))); } - // clear current content of the queue. For some reason, priority_queue does - // not have a clear method - while (!sourceQueue_.empty()) { - sourceQueue_.pop(); - } + clearSourceQueue(); std::vector discoveredFileData = std::move(sharedFileData_); // recreate the queue for (const auto fileData : discoveredFileData) { @@ -157,6 +161,9 @@ void DirectorySourceQueue::setPreviouslyReceivedChunks( } DirectorySourceQueue::~DirectorySourceQueue() { + // need to remove all the sources because they access metadata at the + // destructor. + clearSourceQueue(); for (SourceMetaData *fileData : sharedFileData_) { delete fileData; } diff --git a/DirectorySourceQueue.h b/DirectorySourceQueue.h index c4c45206..07cc4f79 100644 --- a/DirectorySourceQueue.h +++ b/DirectorySourceQueue.h @@ -271,6 +271,9 @@ class DirectorySourceQueue : public SourceQueue { */ void smartNotify(int32_t addedSource); + /// Removes all elements from the source queue + void clearSourceQueue(); + /// root directory to recurse on if fileInfo_ is empty std::string rootDir_; diff --git a/WdtConfig.h b/WdtConfig.h index 9acdcc49..b4ec08dd 100644 --- a/WdtConfig.h +++ b/WdtConfig.h @@ -8,9 +8,9 @@ #define WDT_VERSION_MAJOR 1 #define WDT_VERSION_MINOR 19 -#define WDT_VERSION_BUILD 1509160 +#define WDT_VERSION_BUILD 1509200 // Add -fbcode to version str -#define WDT_VERSION_STR "1.19.1509160-fbcode" +#define WDT_VERSION_STR "1.19.1509200-fbcode" // Tie minor and proto version #define WDT_PROTOCOL_VERSION WDT_VERSION_MINOR