mirror of https://github.com/Icinga/icinga2.git
Merge pull request #10111 from Icinga/unregister-invalid-objects-properly
Unregister invalid config objects properly
This commit is contained in:
commit
88e79ea41a
|
@ -472,13 +472,16 @@ bool ConfigItem::CommitNewItems(const ActivationContext::Ptr& context, WorkQueue
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
std::atomic<int> committed_items(0);
|
std::atomic<int> committed_items(0);
|
||||||
std::mutex newItemsMutex;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
auto items (itemsByType.find(type.get()));
|
auto items (itemsByType.find(type.get()));
|
||||||
|
|
||||||
if (items != itemsByType.end()) {
|
if (items != itemsByType.end()) {
|
||||||
upq.ParallelFor(items->second, [&committed_items, &newItems, &newItemsMutex](const ItemPair& ip) {
|
for (const ItemPair& pair: items->second) {
|
||||||
|
newItems.emplace_back(pair.first);
|
||||||
|
}
|
||||||
|
|
||||||
|
upq.ParallelFor(items->second, [&committed_items](const ItemPair& ip) {
|
||||||
const ConfigItem::Ptr& item = ip.first;
|
const ConfigItem::Ptr& item = ip.first;
|
||||||
|
|
||||||
if (!item->Commit(ip.second)) {
|
if (!item->Commit(ip.second)) {
|
||||||
|
@ -490,9 +493,6 @@ bool ConfigItem::CommitNewItems(const ActivationContext::Ptr& context, WorkQueue
|
||||||
}
|
}
|
||||||
|
|
||||||
committed_items++;
|
committed_items++;
|
||||||
|
|
||||||
std::unique_lock<std::mutex> lock(newItemsMutex);
|
|
||||||
newItems.emplace_back(item);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
upq.Join();
|
upq.Join();
|
||||||
|
|
Loading…
Reference in New Issue