mirror of https://github.com/Icinga/icinga2.git
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;
|
||||
|
||||
if (!DaemonUtility::ValidateConfigFiles(configs, objectsFile))
|
||||
if (!DaemonUtility::ValidateConfigFiles(configs, objectsFile)) {
|
||||
ConfigCompilerContext::GetInstance()->CancelObjectsFile();
|
||||
return false;
|
||||
}
|
||||
|
||||
WorkQueue upq(25000, Application::GetConcurrency());
|
||||
bool result = ConfigItem::CommitItems(ascope.GetContext(), upq, newItems);
|
||||
|
||||
if (!result)
|
||||
if (!result) {
|
||||
ConfigCompilerContext::GetInstance()->CancelObjectsFile();
|
||||
return false;
|
||||
}
|
||||
|
||||
ConfigCompilerContext::GetInstance()->FinishObjectsFile();
|
||||
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)
|
||||
{
|
||||
m_ObjectsFP->Close();
|
||||
|
|
|
@ -36,6 +36,7 @@ class I2_CONFIG_API ConfigCompilerContext
|
|||
public:
|
||||
void OpenObjectsFile(const String& filename);
|
||||
void WriteObject(const Dictionary::Ptr& object);
|
||||
void CancelObjectsFile(void);
|
||||
void FinishObjectsFile(void);
|
||||
|
||||
static ConfigCompilerContext *GetInstance(void);
|
||||
|
|
Loading…
Reference in New Issue