Merge pull request #9284 from Icinga/bugfix/icingadb-array-locking

Add missing array locking in IcingaDB::GetArrayDeletedValues()
This commit is contained in:
Alexander Aleksandrovič Klimov 2022-03-09 19:26:57 +01:00 committed by GitHub
commit fb2a58f177
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 2 deletions

View File

@ -266,14 +266,23 @@ std::vector<Value> IcingaDB::GetArrayDeletedValues(const Array::Ptr& arrayOld, c
}
if (!arrayNew) {
ObjectLock olock (arrayOld);
return std::vector<Value>(arrayOld->Begin(), arrayOld->End());
}
std::vector<Value> vectorOld(arrayOld->Begin(), arrayOld->End());
std::vector<Value> vectorOld;
{
ObjectLock olock (arrayOld);
vectorOld.assign(arrayOld->Begin(), arrayOld->End());
}
std::sort(vectorOld.begin(), vectorOld.end());
vectorOld.erase(std::unique(vectorOld.begin(), vectorOld.end()), vectorOld.end());
std::vector<Value> vectorNew(arrayNew->Begin(), arrayNew->End());
std::vector<Value> vectorNew;
{
ObjectLock olock (arrayNew);
vectorNew.assign(arrayNew->Begin(), arrayNew->End());
}
std::sort(vectorNew.begin(), vectorNew.end());
vectorNew.erase(std::unique(vectorNew.begin(), vectorNew.end()), vectorNew.end());