hold lock while modifying merge states map
@@ -173,8 +173,13 @@ FileStorHandlerImpl::flush(bool killPendingMerges)
LOG(debug, "All queues and bucket locks released.");
if (killPendingMerges) {
+ std::map<document::Bucket, std::shared_ptr<MergeStatus>> my_merge_states;
+ {
+ std::lock_guard mergeGuard(_mergeStatesLock);
+ std::swap(_mergeStates, my_merge_states);
+ }
api::ReturnCode code(api::ReturnCode::ABORTED, "Storage node is shutting down");
- for (auto & entry : _mergeStates) {
+ for (auto & entry : my_merge_states) {
MergeStatus& s(*entry.second);
if (s.pendingGetDiff) {
s.pendingGetDiff->setResult(code);
@@ -189,7 +194,6 @@ FileStorHandlerImpl::flush(bool killPendingMerges)
_messageSender.sendReply(s.reply);
}
}
- _mergeStates.clear();
}
}
