mirror of https://github.com/Icinga/icinga2.git
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()
|
||||
{
|
||||
static ConfigType *ctype;
|
||||
|
||||
if (!ctype) {
|
||||
Type::Ptr type = Type::GetByName("Zone");
|
||||
ctype = dynamic_cast<ConfigType *>(type.get());
|
||||
}
|
||||
|
||||
static ConfigType *ctype = dynamic_cast<ConfigType *>(Type::GetByName("Zone").get());
|
||||
String zoneName = GetZoneName();
|
||||
|
||||
if (!zoneName.IsEmpty())
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "base/function.hpp"
|
||||
#include "base/utility.hpp"
|
||||
#include <boost/algorithm/string/join.hpp>
|
||||
#include <atomic>
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <algorithm>
|
||||
|
@ -462,7 +463,7 @@ bool ConfigItem::CommitNewItems(const ActivationContext::Ptr& context, WorkQueue
|
|||
if (unresolved_dep)
|
||||
continue;
|
||||
|
||||
int committed_items = 0;
|
||||
std::atomic<int> committed_items(0);
|
||||
upq.ParallelFor(items, [&type, &committed_items](const ItemPair& ip) {
|
||||
const ConfigItem::Ptr& item = ip.first;
|
||||
|
||||
|
@ -514,7 +515,7 @@ bool ConfigItem::CommitNewItems(const ActivationContext::Ptr& context, WorkQueue
|
|||
if (unresolved_dep)
|
||||
continue;
|
||||
|
||||
int notified_items = 0;
|
||||
std::atomic<int> notified_items(0);
|
||||
upq.ParallelFor(items, [&type, ¬ified_items](const ItemPair& ip) {
|
||||
const ConfigItem::Ptr& item = ip.first;
|
||||
|
||||
|
|
Loading…
Reference in New Issue