Fix missing object locks

This commit is contained in:
Michael Friedrich 2018-07-04 16:44:44 +02:00
parent 413e351805
commit 3ce8f5599e
1 changed files with 11 additions and 0 deletions

View File

@ -127,18 +127,26 @@ static void CollectScalarVars(Value haystack, std::vector<Value>& path, std::map
const Object::Ptr& obj = haystack.Get<Object::Ptr>();
Dictionary::Ptr dict = dynamic_pointer_cast<Dictionary>(obj);
if (dict) {
ObjectLock olock(dict);
for (auto& kv : dict) {
path.emplace_back(kv.first);
CollectScalarVars(kv.second, path, needles);
path.pop_back();
}
break;
}
Array::Ptr arr = dynamic_pointer_cast<Array>(obj);
if (arr) {
double index = 0.0;
ObjectLock xlock(arr);
for (auto& v : arr) {
path.emplace_back(index);
CollectScalarVars(v, path, needles);
@ -146,6 +154,7 @@ static void CollectScalarVars(Value haystack, std::vector<Value>& path, std::map
index += 1.0;
}
break;
}
}
@ -227,6 +236,8 @@ Dictionary::Ptr RedisWriter::SerializeVars(const CustomVarObject::Ptr& object)
auto env (GetEnvironment());
auto envChecksum (SHA1(env));
ObjectLock olock(vars);
for (auto& kv : vars) {
Dictionary::Ptr flatVars = new Dictionary();