Skip to content

Commit

Permalink
Ensuring that file byte source is deleted before metadata is deleted
Browse files Browse the repository at this point in the history
Summary: Ensuring that file byte source is deleted before metadata is deleted

Reviewed By: @ldemailly

Differential Revision: D2460832

committer: Service User <[email protected]>
  • Loading branch information
uddipta authored and ldemailly committed Sep 21, 2015
1 parent 4bfe52a commit 32ee48d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
17 changes: 12 additions & 5 deletions DirectorySourceQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<FileChunksInfo> &previouslyTransferredChunks) {
std::unique_lock<std::mutex> lock(mutex_);
Expand All @@ -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<SourceMetaData *> discoveredFileData = std::move(sharedFileData_);
// recreate the queue
for (const auto fileData : discoveredFileData) {
Expand All @@ -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;
}
Expand Down
3 changes: 3 additions & 0 deletions DirectorySourceQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_;

Expand Down
4 changes: 2 additions & 2 deletions WdtConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 32ee48d

Please sign in to comment.