Fix crash in DbConnection::ProgramStatusHandler

fixes #8288
This commit is contained in:
Gunnar Beutner 2015-01-27 09:53:07 +01:00
parent b858a05f15
commit e7938c9374
2 changed files with 7 additions and 5 deletions

View File

@ -26,7 +26,6 @@
#include "base/convert.hpp"
#include "base/objectlock.hpp"
#include "base/utility.hpp"
#include "base/initialize.hpp"
#include "base/logger.hpp"
#include "base/function.hpp"
#include "base/exception.hpp"
@ -38,8 +37,7 @@ REGISTER_TYPE(DbConnection);
REGISTER_SCRIPTFUNCTION(ValidateFailoverTimeout, &DbConnection::ValidateFailoverTimeout);
Timer::Ptr DbConnection::m_ProgramStatusTimer;
INITIALIZE_ONCE(&DbConnection::StaticInitialize);
boost::once_flag DbConnection::m_OnceFlag = BOOST_ONCE_INIT;
void DbConnection::OnConfigLoaded(void)
{
@ -51,6 +49,8 @@ void DbConnection::OnConfigLoaded(void)
SetHAMode(HARunEverywhere);
}
boost::call_once(m_OnceFlag, InitializeDbTimer);
}
void DbConnection::Start(void)
@ -83,7 +83,7 @@ void DbConnection::Pause(void)
m_CleanUpTimer.reset();
}
void DbConnection::StaticInitialize(void)
void DbConnection::InitializeDbTimer(void)
{
m_ProgramStatusTimer = new Timer();
m_ProgramStatusTimer->SetInterval(10);

View File

@ -25,6 +25,7 @@
#include "db_ido/dbobject.hpp"
#include "db_ido/dbquery.hpp"
#include "base/timer.hpp"
#include <boost/thread/once.hpp>
namespace icinga
{
@ -39,7 +40,7 @@ class I2_DB_IDO_API DbConnection : public ObjectImpl<DbConnection>
public:
DECLARE_OBJECT(DbConnection);
static void StaticInitialize(void);
static void InitializeDbTimer(void);
void SetObjectID(const DbObject::Ptr& dbobj, const DbReference& dbref);
DbReference GetObjectID(const DbObject::Ptr& dbobj) const;
@ -96,6 +97,7 @@ private:
virtual void ClearConfigTable(const String& table) = 0;
static Timer::Ptr m_ProgramStatusTimer;
static boost::once_flag m_OnceFlag;
static void InsertRuntimeVariable(const String& key, const Value& value);
static void ProgramStatusHandler(void);