Skip to content

Commit 32ee48d

Browse files
uddiptaldemailly
authored andcommitted
Ensuring that file byte source is deleted before metadata is deleted
Summary: Ensuring that file byte source is deleted before metadata is deleted Reviewed By: @ldemailly Differential Revision: D2460832 committer: Service User <[email protected]>
1 parent 4bfe52a commit 32ee48d

4 files changed

+18
-8
lines changed

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ cmake_minimum_required(VERSION 3.2)
2222
# There is no C per se in WDT but if you use CXX only here many checks fail
2323
# Version is Major.Minor.YYMMDDX for up to 10 releases per day
2424
# Minor currently is also the protocol version - has to match with Protocol.cpp
25-
project("WDT" LANGUAGES C CXX VERSION 1.19.1509160)
25+
project("WDT" LANGUAGES C CXX VERSION 1.19.1509200)
2626

2727
# On MacOS this requires the latest (master) CMake (and/or CMake 3.1.1/3.2)
2828
set(CMAKE_CXX_STANDARD 11)

DirectorySourceQueue.cpp

+12-5
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,14 @@ bool DirectorySourceQueue::setRootDir(const string &newRootDir) {
128128
return true;
129129
}
130130

131+
void DirectorySourceQueue::clearSourceQueue() {
132+
// clear current content of the queue. For some reason, priority_queue does
133+
// not have a clear method
134+
while (!sourceQueue_.empty()) {
135+
sourceQueue_.pop();
136+
}
137+
}
138+
131139
void DirectorySourceQueue::setPreviouslyReceivedChunks(
132140
std::vector<FileChunksInfo> &previouslyTransferredChunks) {
133141
std::unique_lock<std::mutex> lock(mutex_);
@@ -142,11 +150,7 @@ void DirectorySourceQueue::setPreviouslyReceivedChunks(
142150
previouslyTransferredChunks_.insert(
143151
std::make_pair(chunkInfo.getFileName(), std::move(chunkInfo)));
144152
}
145-
// clear current content of the queue. For some reason, priority_queue does
146-
// not have a clear method
147-
while (!sourceQueue_.empty()) {
148-
sourceQueue_.pop();
149-
}
153+
clearSourceQueue();
150154
std::vector<SourceMetaData *> discoveredFileData = std::move(sharedFileData_);
151155
// recreate the queue
152156
for (const auto fileData : discoveredFileData) {
@@ -157,6 +161,9 @@ void DirectorySourceQueue::setPreviouslyReceivedChunks(
157161
}
158162

159163
DirectorySourceQueue::~DirectorySourceQueue() {
164+
// need to remove all the sources because they access metadata at the
165+
// destructor.
166+
clearSourceQueue();
160167
for (SourceMetaData *fileData : sharedFileData_) {
161168
delete fileData;
162169
}

DirectorySourceQueue.h

+3
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,9 @@ class DirectorySourceQueue : public SourceQueue {
271271
*/
272272
void smartNotify(int32_t addedSource);
273273

274+
/// Removes all elements from the source queue
275+
void clearSourceQueue();
276+
274277
/// root directory to recurse on if fileInfo_ is empty
275278
std::string rootDir_;
276279

WdtConfig.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
#define WDT_VERSION_MAJOR 1
1010
#define WDT_VERSION_MINOR 19
11-
#define WDT_VERSION_BUILD 1509160
11+
#define WDT_VERSION_BUILD 1509200
1212
// Add -fbcode to version str
13-
#define WDT_VERSION_STR "1.19.1509160-fbcode"
13+
#define WDT_VERSION_STR "1.19.1509200-fbcode"
1414
// Tie minor and proto version
1515
#define WDT_PROTOCOL_VERSION WDT_VERSION_MINOR
1616

0 commit comments

Comments
 (0)