mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-24 22:24:44 +02:00
Merge pull request #9256 from Icinga/bugfix/add-some-missing-locks
Add some missing locks to prevent data races
This commit is contained in:
commit
3fee562e7a
@ -413,13 +413,7 @@ void ConfigObject::OnConfigLoaded()
|
|||||||
|
|
||||||
void ConfigObject::OnAllConfigLoaded()
|
void ConfigObject::OnAllConfigLoaded()
|
||||||
{
|
{
|
||||||
static ConfigType *ctype;
|
static ConfigType *ctype = dynamic_cast<ConfigType *>(Type::GetByName("Zone").get());
|
||||||
|
|
||||||
if (!ctype) {
|
|
||||||
Type::Ptr type = Type::GetByName("Zone");
|
|
||||||
ctype = dynamic_cast<ConfigType *>(type.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
String zoneName = GetZoneName();
|
String zoneName = GetZoneName();
|
||||||
|
|
||||||
if (!zoneName.IsEmpty())
|
if (!zoneName.IsEmpty())
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "base/function.hpp"
|
#include "base/function.hpp"
|
||||||
#include "base/utility.hpp"
|
#include "base/utility.hpp"
|
||||||
#include <boost/algorithm/string/join.hpp>
|
#include <boost/algorithm/string/join.hpp>
|
||||||
|
#include <atomic>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@ -462,7 +463,7 @@ bool ConfigItem::CommitNewItems(const ActivationContext::Ptr& context, WorkQueue
|
|||||||
if (unresolved_dep)
|
if (unresolved_dep)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int committed_items = 0;
|
std::atomic<int> committed_items(0);
|
||||||
upq.ParallelFor(items, [&type, &committed_items](const ItemPair& ip) {
|
upq.ParallelFor(items, [&type, &committed_items](const ItemPair& ip) {
|
||||||
const ConfigItem::Ptr& item = ip.first;
|
const ConfigItem::Ptr& item = ip.first;
|
||||||
|
|
||||||
@ -514,7 +515,7 @@ bool ConfigItem::CommitNewItems(const ActivationContext::Ptr& context, WorkQueue
|
|||||||
if (unresolved_dep)
|
if (unresolved_dep)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int notified_items = 0;
|
std::atomic<int> notified_items(0);
|
||||||
upq.ParallelFor(items, [&type, ¬ified_items](const ItemPair& ip) {
|
upq.ParallelFor(items, [&type, ¬ified_items](const ItemPair& ip) {
|
||||||
const ConfigItem::Ptr& item = ip.first;
|
const ConfigItem::Ptr& item = ip.first;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user