mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-30 00:54:30 +02:00
Remove temporary icinga2.debug file in case the config validation fails
fixes #12318
This commit is contained in:
parent
d0658c465b
commit
46f8c7eb59
@ -162,14 +162,18 @@ bool DaemonUtility::LoadConfigFiles(const std::vector<std::string>& configs,
|
|||||||
{
|
{
|
||||||
ActivationScope ascope;
|
ActivationScope ascope;
|
||||||
|
|
||||||
if (!DaemonUtility::ValidateConfigFiles(configs, objectsFile))
|
if (!DaemonUtility::ValidateConfigFiles(configs, objectsFile)) {
|
||||||
|
ConfigCompilerContext::GetInstance()->CancelObjectsFile();
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
WorkQueue upq(25000, Application::GetConcurrency());
|
WorkQueue upq(25000, Application::GetConcurrency());
|
||||||
bool result = ConfigItem::CommitItems(ascope.GetContext(), upq, newItems);
|
bool result = ConfigItem::CommitItems(ascope.GetContext(), upq, newItems);
|
||||||
|
|
||||||
if (!result)
|
if (!result) {
|
||||||
|
ConfigCompilerContext::GetInstance()->CancelObjectsFile();
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
ConfigCompilerContext::GetInstance()->FinishObjectsFile();
|
ConfigCompilerContext::GetInstance()->FinishObjectsFile();
|
||||||
ScriptGlobal::WriteToFile(varsfile);
|
ScriptGlobal::WriteToFile(varsfile);
|
||||||
|
@ -58,6 +58,18 @@ void ConfigCompilerContext::WriteObject(const Dictionary::Ptr& object)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ConfigCompilerContext::CancelObjectsFile(void)
|
||||||
|
{
|
||||||
|
m_ObjectsFP->Close();
|
||||||
|
m_ObjectsFP.reset();
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
_unlink(m_ObjectsTempFile.CStr());
|
||||||
|
#else /* _WIN32 */
|
||||||
|
unlink(m_ObjectsTempFile.CStr());
|
||||||
|
#endif /* _WIN32 */
|
||||||
|
}
|
||||||
|
|
||||||
void ConfigCompilerContext::FinishObjectsFile(void)
|
void ConfigCompilerContext::FinishObjectsFile(void)
|
||||||
{
|
{
|
||||||
m_ObjectsFP->Close();
|
m_ObjectsFP->Close();
|
||||||
|
@ -36,6 +36,7 @@ class I2_CONFIG_API ConfigCompilerContext
|
|||||||
public:
|
public:
|
||||||
void OpenObjectsFile(const String& filename);
|
void OpenObjectsFile(const String& filename);
|
||||||
void WriteObject(const Dictionary::Ptr& object);
|
void WriteObject(const Dictionary::Ptr& object);
|
||||||
|
void CancelObjectsFile(void);
|
||||||
void FinishObjectsFile(void);
|
void FinishObjectsFile(void);
|
||||||
|
|
||||||
static ConfigCompilerContext *GetInstance(void);
|
static ConfigCompilerContext *GetInstance(void);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user