Refactor #includes (Part 4).

This commit is contained in:
Gunnar Beutner 2013-03-18 11:02:18 +01:00
parent 2e8685c622
commit c3975af6ec
62 changed files with 689 additions and 776 deletions

View File

@ -23,6 +23,10 @@
#include "icinga/service.h" #include "icinga/service.h"
#include "remoting/endpoint.h" #include "remoting/endpoint.h"
#include "base/dynamicobject.h" #include "base/dynamicobject.h"
#include "base/timer.h"
#include <boost/thread/thread.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/condition_variable.hpp>
#include <boost/multi_index_container.hpp> #include <boost/multi_index_container.hpp>
#include <boost/multi_index/ordered_index.hpp> #include <boost/multi_index/ordered_index.hpp>
#include <boost/multi_index/key_extractors.hpp> #include <boost/multi_index/key_extractors.hpp>

View File

@ -30,6 +30,7 @@
#include "base/application.h" #include "base/application.h"
#include <boost/smart_ptr/make_shared.hpp> #include <boost/smart_ptr/make_shared.hpp>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/exception/diagnostic_information.hpp> #include <boost/exception/diagnostic_information.hpp>
#include <fstream> #include <fstream>
@ -213,7 +214,7 @@ void CompatComponent::DumpComments(std::ostream& fp, const Service::Ptr& owner,
String id; String id;
Dictionary::Ptr comment; Dictionary::Ptr comment;
BOOST_FOREACH(tie(id, comment), comments) { BOOST_FOREACH(boost::tie(id, comment), comments) {
if (Service::IsCommentExpired(comment)) if (Service::IsCommentExpired(comment))
continue; continue;
@ -253,7 +254,7 @@ void CompatComponent::DumpDowntimes(std::ostream& fp, const Service::Ptr& owner,
String id; String id;
Dictionary::Ptr downtime; Dictionary::Ptr downtime;
BOOST_FOREACH(tie(id, downtime), downtimes) { BOOST_FOREACH(boost::tie(id, downtime), downtimes) {
if (Service::IsDowntimeExpired(downtime)) if (Service::IsDowntimeExpired(downtime))
continue; continue;

View File

@ -24,6 +24,8 @@
#include "icinga/service.h" #include "icinga/service.h"
#include "base/dynamicobject.h" #include "base/dynamicobject.h"
#include "base/objectlock.h" #include "base/objectlock.h"
#include "base/timer.h"
#include <boost/thread/thread.hpp>
#include <iostream> #include <iostream>
namespace icinga namespace icinga

View File

@ -24,6 +24,7 @@
#include <algorithm> #include <algorithm>
#include "base/dynamictype.h" #include "base/dynamictype.h"
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <boost/tuple/tuple.hpp>
using namespace icinga; using namespace icinga;
@ -208,7 +209,7 @@ void DelegationComponent::DelegationTimerHandler(void)
Endpoint::Ptr endpoint; Endpoint::Ptr endpoint;
int count; int count;
BOOST_FOREACH(tie(endpoint, count), histogram) { BOOST_FOREACH(boost::tie(endpoint, count), histogram) {
std::ostringstream msgbuf; std::ostringstream msgbuf;
msgbuf << "histogram: " << endpoint->GetName() << " - " << count; msgbuf << "histogram: " << endpoint->GetName() << " - " << count;
Log(LogInformation, "delegation", msgbuf.str()); Log(LogInformation, "delegation", msgbuf.str());

View File

@ -23,6 +23,7 @@
#include "icinga/service.h" #include "icinga/service.h"
#include "remoting/endpoint.h" #include "remoting/endpoint.h"
#include "base/dynamicobject.h" #include "base/dynamicobject.h"
#include "base/timer.h"
namespace icinga namespace icinga
{ {

View File

@ -22,6 +22,7 @@
#include "remoting/endpoint.h" #include "remoting/endpoint.h"
#include "base/dynamicobject.h" #include "base/dynamicobject.h"
#include "base/timer.h"
namespace icinga namespace icinga
{ {

View File

@ -30,6 +30,7 @@
#include <boost/algorithm/string/classification.hpp> #include <boost/algorithm/string/classification.hpp>
#include <boost/smart_ptr/make_shared.hpp> #include <boost/smart_ptr/make_shared.hpp>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <boost/algorithm/string/split.hpp>
using namespace icinga; using namespace icinga;
using namespace livestatus; using namespace livestatus;
@ -74,11 +75,12 @@ Query::Query(const std::vector<String>& lines)
else if (header == "OutputFormat") else if (header == "OutputFormat")
m_OutputFormat = params; m_OutputFormat = params;
else if (header == "Columns") else if (header == "Columns")
m_Columns = params.Split(boost::is_any_of(" ")); boost::algorithm::split(m_Columns, params, boost::is_any_of(" "));
else if (header == "ColumnHeaders") else if (header == "ColumnHeaders")
m_ColumnHeaders = (params == "on"); m_ColumnHeaders = (params == "on");
else if (header == "Filter" || header == "Stats") { else if (header == "Filter" || header == "Stats") {
std::vector<String> tokens = params.Split(boost::is_any_of(" ")); std::vector<String> tokens;
boost::algorithm::split(tokens, params, boost::is_any_of(" "));
if (tokens.size() == 2) if (tokens.size() == 2)
tokens.push_back(""); tokens.push_back("");

View File

@ -22,6 +22,7 @@
#include "livestatus/column.h" #include "livestatus/column.h"
#include "base/object.h" #include "base/object.h"
#include <vector>
namespace livestatus namespace livestatus
{ {

View File

@ -22,6 +22,7 @@
#include "remoting/endpoint.h" #include "remoting/endpoint.h"
#include "base/dynamicobject.h" #include "base/dynamicobject.h"
#include "base/timer.h"
namespace icinga namespace icinga
{ {

View File

@ -21,6 +21,7 @@
#include "config/configcompiler.h" #include "config/configcompiler.h"
#include "base/application.h" #include "base/application.h"
#include "base/logger_fwd.h" #include "base/logger_fwd.h"
#include "base/timer.h"
#include <boost/program_options.hpp> #include <boost/program_options.hpp>
#include <boost/tuple/tuple.hpp> #include <boost/tuple/tuple.hpp>
#include <boost/smart_ptr/make_shared.hpp> #include <boost/smart_ptr/make_shared.hpp>
@ -40,8 +41,8 @@ static po::variables_map g_AppParams;
static String g_ConfigUnit; static String g_ConfigUnit;
#ifndef _WIN32 #ifndef _WIN32
static bool g_ReloadConfig = false; static bool l_ReloadConfig = false;
static Timer::Ptr g_ReloadConfigTimer; static Timer::Ptr l_ReloadConfigTimer;
#endif /* _WIN32 */ #endif /* _WIN32 */
static bool LoadConfigFiles(bool validateOnly) static bool LoadConfigFiles(bool validateOnly)
@ -109,11 +110,11 @@ static bool LoadConfigFiles(bool validateOnly)
#ifndef _WIN32 #ifndef _WIN32
static void ReloadConfigTimerHandler(void) static void ReloadConfigTimerHandler(void)
{ {
if (g_ReloadConfig) { if (l_ReloadConfig) {
Log(LogInformation, "icinga-app", "Received SIGHUP. Reloading config files."); Log(LogInformation, "icinga-app", "Received SIGHUP. Reloading config files.");
LoadConfigFiles(false); LoadConfigFiles(false);
g_ReloadConfig = false; l_ReloadConfig = false;
} }
} }
@ -121,7 +122,7 @@ static void SigHupHandler(int signum)
{ {
ASSERT(signum == SIGHUP); ASSERT(signum == SIGHUP);
g_ReloadConfig = true; l_ReloadConfig = true;
} }
#endif /* _WIN32 */ #endif /* _WIN32 */
@ -281,10 +282,10 @@ int main(int argc, char **argv)
sa.sa_handler = &SigHupHandler; sa.sa_handler = &SigHupHandler;
sigaction(SIGHUP, &sa, NULL); sigaction(SIGHUP, &sa, NULL);
g_ReloadConfigTimer = boost::make_shared<Timer>(); l_ReloadConfigTimer = boost::make_shared<Timer>();
g_ReloadConfigTimer->SetInterval(1); l_ReloadConfigTimer->SetInterval(1);
g_ReloadConfigTimer->OnTimerExpired.connect(boost::bind(&ReloadConfigTimerHandler)); l_ReloadConfigTimer->OnTimerExpired.connect(boost::bind(&ReloadConfigTimerHandler));
g_ReloadConfigTimer->Start(); l_ReloadConfigTimer->Start();
#endif /* _WIN32 */ #endif /* _WIN32 */
return app->Run(); return app->Run();

View File

@ -23,6 +23,7 @@
#include "base/logger_fwd.h" #include "base/logger_fwd.h"
#include "base/exception.h" #include "base/exception.h"
#include "base/objectlock.h" #include "base/objectlock.h"
#include "base/utility.h"
#include <sstream> #include <sstream>
#include <boost/algorithm/string/classification.hpp> #include <boost/algorithm/string/classification.hpp>
#include <boost/thread/thread.hpp> #include <boost/thread/thread.hpp>
@ -30,6 +31,7 @@
#include <boost/make_shared.hpp> #include <boost/make_shared.hpp>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <boost/exception/diagnostic_information.hpp> #include <boost/exception/diagnostic_information.hpp>
#include <boost/algorithm/string/split.hpp>
#include <iostream> #include <iostream>
using namespace icinga; using namespace icinga;

View File

@ -22,7 +22,7 @@
using namespace icinga; using namespace icinga;
boost::mutex AttributeBase::m_Mutex; static boost::mutex l_Mutex;
AttributeBase::AttributeBase(void) AttributeBase::AttributeBase(void)
: m_Value() : m_Value()
@ -33,7 +33,7 @@ AttributeBase::AttributeBase(void)
*/ */
void AttributeBase::Set(const Value& value) void AttributeBase::Set(const Value& value)
{ {
boost::mutex::scoped_lock lock(m_Mutex); boost::mutex::scoped_lock lock(l_Mutex);
InternalSet(value); InternalSet(value);
} }
@ -42,7 +42,7 @@ void AttributeBase::Set(const Value& value)
*/ */
Value AttributeBase::Get(void) const Value AttributeBase::Get(void) const
{ {
boost::mutex::scoped_lock lock(m_Mutex); boost::mutex::scoped_lock lock(l_Mutex);
return InternalGet(); return InternalGet();
} }
@ -51,7 +51,7 @@ Value AttributeBase::Get(void) const
*/ */
AttributeBase::operator Value(void) const AttributeBase::operator Value(void) const
{ {
boost::mutex::scoped_lock lock(m_Mutex); boost::mutex::scoped_lock lock(l_Mutex);
return InternalGet(); return InternalGet();
} }
@ -60,12 +60,12 @@ AttributeBase::operator Value(void) const
*/ */
bool AttributeBase::IsEmpty(void) const bool AttributeBase::IsEmpty(void) const
{ {
boost::mutex::scoped_lock lock(m_Mutex); boost::mutex::scoped_lock lock(l_Mutex);
return InternalGet().IsEmpty(); return InternalGet().IsEmpty();
} }
/** /**
* @threadsafety Caller must hold m_Mutex; * @threadsafety Caller must hold l_Mutex;
*/ */
void AttributeBase::InternalSet(const Value& value) void AttributeBase::InternalSet(const Value& value)
{ {
@ -73,7 +73,7 @@ void AttributeBase::InternalSet(const Value& value)
} }
/** /**
* @threadsafety Caller must hold m_Mutex. * @threadsafety Caller must hold l_Mutex.
*/ */
const Value& AttributeBase::InternalGet(void) const const Value& AttributeBase::InternalGet(void) const
{ {

View File

@ -64,8 +64,6 @@ protected:
void InternalSet(const Value& value); void InternalSet(const Value& value);
const Value& InternalGet(void) const; const Value& InternalGet(void) const;
static boost::mutex m_Mutex;
private: private:
Value m_Value; Value m_Value;
@ -82,8 +80,7 @@ public:
*/ */
void Set(const T& value) void Set(const T& value)
{ {
boost::mutex::scoped_lock lock(m_Mutex); AttributeBase::Set(value);
InternalSet(value);
} }
/** /**
@ -97,12 +94,7 @@ public:
T Get(void) const T Get(void) const
{ {
Value value; Value value = AttributeBase::Get();
{
boost::mutex::scoped_lock lock(m_Mutex);
value = InternalGet();
}
if (value.IsEmpty()) if (value.IsEmpty())
return T(); return T();

View File

@ -22,20 +22,23 @@
#include "base/netstring.h" #include "base/netstring.h"
#include "base/registry.h" #include "base/registry.h"
#include "base/stdiostream.h" #include "base/stdiostream.h"
#include "base/utility.h"
#include "base/objectlock.h" #include "base/objectlock.h"
#include "base/logger_fwd.h" #include "base/logger_fwd.h"
#include "base/exception.h" #include "base/exception.h"
#include "base/timer.h"
#include "base/scripttask.h"
#include <fstream> #include <fstream>
#include <boost/make_shared.hpp> #include <boost/make_shared.hpp>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
using namespace icinga; using namespace icinga;
double DynamicObject::m_CurrentTx = 0; static double l_CurrentTx = 0;
std::set<DynamicObject::WeakPtr> DynamicObject::m_ModifiedObjects; static std::set<DynamicObject::WeakPtr> l_ModifiedObjects;
boost::mutex DynamicObject::m_TransactionMutex; static boost::mutex l_TransactionMutex;
boost::once_flag DynamicObject::m_TransactionOnce = BOOST_ONCE_INIT; static boost::once_flag l_TransactionOnce = BOOST_ONCE_INIT;
Timer::Ptr DynamicObject::m_TransactionTimer; static Timer::Ptr l_TransactionTimer;
boost::signals2::signal<void (const DynamicObject::Ptr&)> DynamicObject::OnRegistered; boost::signals2::signal<void (const DynamicObject::Ptr&)> DynamicObject::OnRegistered;
boost::signals2::signal<void (const DynamicObject::Ptr&)> DynamicObject::OnUnregistered; boost::signals2::signal<void (const DynamicObject::Ptr&)> DynamicObject::OnUnregistered;
@ -59,7 +62,7 @@ DynamicObject::DynamicObject(const Dictionary::Ptr& serializedObject)
* non-config state after the object has been fully constructed */ * non-config state after the object has been fully constructed */
ApplyUpdate(serializedObject, Attribute_Config); ApplyUpdate(serializedObject, Attribute_Config);
boost::call_once(m_TransactionOnce, &DynamicObject::Initialize); boost::call_once(l_TransactionOnce, &DynamicObject::Initialize);
} }
/* /*
@ -71,10 +74,10 @@ DynamicObject::~DynamicObject(void)
void DynamicObject::Initialize(void) void DynamicObject::Initialize(void)
{ {
/* Set up a timer to periodically create a new transaction. */ /* Set up a timer to periodically create a new transaction. */
m_TransactionTimer = boost::make_shared<Timer>(); l_TransactionTimer = boost::make_shared<Timer>();
m_TransactionTimer->SetInterval(0.5); l_TransactionTimer->SetInterval(0.5);
m_TransactionTimer->OnTimerExpired.connect(boost::bind(&DynamicObject::NewTx)); l_TransactionTimer->OnTimerExpired.connect(boost::bind(&DynamicObject::NewTx));
m_TransactionTimer->Start(); l_TransactionTimer->Start();
} }
Dictionary::Ptr DynamicObject::BuildUpdate(double sinceTx, int attributeTypes) const Dictionary::Ptr DynamicObject::BuildUpdate(double sinceTx, int attributeTypes) const
@ -249,8 +252,8 @@ void DynamicObject::Touch(const String& name)
m_ModifiedAttributes.insert(name); m_ModifiedAttributes.insert(name);
{ {
boost::mutex::scoped_lock lock(m_TransactionMutex); boost::mutex::scoped_lock lock(l_TransactionMutex);
m_ModifiedObjects.insert(GetSelf()); l_ModifiedObjects.insert(GetSelf());
} }
} }
@ -300,8 +303,8 @@ void DynamicObject::InternalSetAttribute(const String& name, const Value& data,
* do it here. */ * do it here. */
{ {
boost::mutex::scoped_lock lock(m_TransactionMutex); boost::mutex::scoped_lock lock(l_TransactionMutex);
m_ModifiedObjects.insert(GetSelf()); l_ModifiedObjects.insert(GetSelf());
} }
} }
@ -382,8 +385,8 @@ void DynamicObject::Register(void)
* We're doing this here because we can't construct * We're doing this here because we can't construct
* a while WeakPtr from within the object's constructor. */ * a while WeakPtr from within the object's constructor. */
{ {
boost::mutex::scoped_lock lock(m_TransactionMutex); boost::mutex::scoped_lock lock(l_TransactionMutex);
m_ModifiedObjects.insert(GetSelf()); l_ModifiedObjects.insert(GetSelf());
} }
DynamicType::Ptr dtype = GetType(); DynamicType::Ptr dtype = GetType();
@ -587,14 +590,14 @@ void DynamicObject::DeactivateObjects(void)
*/ */
double DynamicObject::GetCurrentTx(void) double DynamicObject::GetCurrentTx(void)
{ {
boost::mutex::scoped_lock lock(m_TransactionMutex); boost::mutex::scoped_lock lock(l_TransactionMutex);
if (m_CurrentTx == 0) { if (l_CurrentTx == 0) {
/* Set the initial transaction ID. */ /* Set the initial transaction ID. */
m_CurrentTx = Utility::GetTime(); l_CurrentTx = Utility::GetTime();
} }
return m_CurrentTx; return l_CurrentTx;
} }
void DynamicObject::Flush(void) void DynamicObject::Flush(void)
@ -611,11 +614,11 @@ void DynamicObject::NewTx(void)
std::set<DynamicObject::WeakPtr> objects; std::set<DynamicObject::WeakPtr> objects;
{ {
boost::mutex::scoped_lock lock(m_TransactionMutex); boost::mutex::scoped_lock lock(l_TransactionMutex);
tx = m_CurrentTx; tx = l_CurrentTx;
m_ModifiedObjects.swap(objects); l_ModifiedObjects.swap(objects);
m_CurrentTx = Utility::GetTime(); l_CurrentTx = Utility::GetTime();
} }
BOOST_FOREACH(const DynamicObject::WeakPtr& wobject, objects) { BOOST_FOREACH(const DynamicObject::WeakPtr& wobject, objects) {

View File

@ -21,14 +21,13 @@
#define DYNAMICOBJECT_H #define DYNAMICOBJECT_H
#include "base/i2-base.h" #include "base/i2-base.h"
#include "base/timer.h"
#include "base/attribute.h" #include "base/attribute.h"
#include "base/scripttask.h" #include "base/scripttask.h"
#include "base/object.h" #include "base/object.h"
#include "base/dictionary.h" #include "base/dictionary.h"
#include <boost/signals2.hpp>
#include <map> #include <map>
#include <set> #include <set>
#include <boost/thread/once.hpp>
namespace icinga namespace icinga
{ {
@ -133,13 +132,6 @@ private:
static void NewTx(void); static void NewTx(void);
/* This has to be a set of raw pointers because the DynamicObject
* constructor has to be able to insert objects into this list. */
static std::set<DynamicObject::WeakPtr> m_ModifiedObjects;
static boost::mutex m_TransactionMutex;
static boost::once_flag m_TransactionOnce;
static Timer::Ptr m_TransactionTimer;
friend class DynamicType; /* for OnRegistrationCompleted. */ friend class DynamicType; /* for OnRegistrationCompleted. */
}; };

View File

@ -18,6 +18,7 @@
******************************************************************************/ ******************************************************************************/
#include "base/dynamictype.h" #include "base/dynamictype.h"
#include "base/utility.h"
#include "base/objectlock.h" #include "base/objectlock.h"
using namespace icinga; using namespace icinga;

View File

@ -21,6 +21,7 @@
#include "base/streamlogger.h" #include "base/streamlogger.h"
#include "base/sysloglogger.h" #include "base/sysloglogger.h"
#include "base/dynamictype.h" #include "base/dynamictype.h"
#include "base/utility.h"
#include "base/objectlock.h" #include "base/objectlock.h"
#include <boost/make_shared.hpp> #include <boost/make_shared.hpp>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>

View File

@ -27,6 +27,7 @@
#include <boost/tuple/tuple.hpp> #include <boost/tuple/tuple.hpp>
#include <boost/make_shared.hpp> #include <boost/make_shared.hpp>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <boost/thread/thread.hpp>
#ifndef _WIN32 #ifndef _WIN32
#include <execvpe.h> #include <execvpe.h>

View File

@ -131,11 +131,6 @@ void String::Replace(size_t first, size_t second, const String& str)
m_Data.replace(first, second, str); m_Data.replace(first, second, str);
} }
String Join(const std::vector<String>& strings, const char *delim)
{
return boost::algorithm::join(strings, delim);
}
void String::Trim(void) void String::Trim(void)
{ {
boost::algorithm::trim(m_Data); boost::algorithm::trim(m_Data);

View File

@ -23,8 +23,6 @@
#include "base/i2-base.h" #include "base/i2-base.h"
#include <ostream> #include <ostream>
#include <istream> #include <istream>
#include <vector>
#include <boost/algorithm/string/split.hpp>
namespace icinga { namespace icinga {
@ -79,16 +77,6 @@ public:
String SubStr(size_t first, size_t len = NPos) const; String SubStr(size_t first, size_t len = NPos) const;
void Replace(size_t first, size_t second, const String& str); void Replace(size_t first, size_t second, const String& str);
template<typename Predicate>
std::vector<String> Split(const Predicate& predicate) const
{
std::vector<String> tokens;
boost::algorithm::split(tokens, m_Data, predicate);
return tokens;
}
static String Join(const std::vector<String>& strings, const char *delim);
void Trim(void); void Trim(void);
void swap(String& str); void swap(String& str);

View File

@ -22,6 +22,7 @@
#include "base/i2-base.h" #include "base/i2-base.h"
#include "base/script.h" #include "base/script.h"
#include "base/scripttask.h"
#include <vector> #include <vector>
#include <set> #include <set>

View File

@ -18,7 +18,9 @@
******************************************************************************/ ******************************************************************************/
#include "base/streamlogger.h" #include "base/streamlogger.h"
#include "base/utility.h"
#include "base/objectlock.h" #include "base/objectlock.h"
#include <boost/thread/thread.hpp>
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>

View File

@ -19,32 +19,55 @@
#include "base/timer.h" #include "base/timer.h"
#include "base/application.h" #include "base/application.h"
#include "base/utility.h"
#include <boost/bind.hpp> #include <boost/bind.hpp>
#include <boost/thread/thread.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/condition_variable.hpp>
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/ordered_index.hpp>
#include <boost/multi_index/key_extractors.hpp>
using namespace icinga; using namespace icinga;
Timer::TimerSet Timer::m_Timers;
boost::thread Timer::m_Thread;
boost::mutex Timer::m_Mutex;
boost::condition_variable Timer::m_CV;
bool Timer::m_StopThread;
/** /**
* Extracts the next timestamp from a Timer. * @ingroup base
*
* @param wtimer Weak pointer to the timer.
* @returns The next timestamp
* @threadsafety Caller must hold Timer::m_Mutex.
*/ */
double TimerNextExtractor::operator()(const Timer::WeakPtr& wtimer) struct icinga::TimerNextExtractor
{ {
Timer::Ptr timer = wtimer.lock(); typedef double result_type;
if (!timer) /**
return 0; * Extracts the next timestamp from a Timer.
*
* @param wtimer Weak pointer to the timer.
* @returns The next timestamp
* @threadsafety Caller must hold l_Mutex.
*/
double operator()(const weak_ptr<Timer>& wtimer)
{
Timer::Ptr timer = wtimer.lock();
return timer->m_Next; if (!timer)
} return 0;
return timer->m_Next;
}
};
typedef boost::multi_index_container<
Timer::WeakPtr,
boost::multi_index::indexed_by<
boost::multi_index::ordered_unique<boost::multi_index::identity<Timer::WeakPtr> >,
boost::multi_index::ordered_non_unique<TimerNextExtractor>
>
> TimerSet;
static boost::mutex l_Mutex;
static boost::condition_variable l_CV;
static boost::thread l_Thread;
static bool l_StopThread;
static TimerSet l_Timers;
/** /**
* Constructor for the Timer class. * Constructor for the Timer class.
@ -62,9 +85,9 @@ Timer::Timer(void)
*/ */
void Timer::Initialize(void) void Timer::Initialize(void)
{ {
boost::mutex::scoped_lock lock(m_Mutex); boost::mutex::scoped_lock lock(l_Mutex);
m_StopThread = false; l_StopThread = false;
m_Thread = boost::thread(boost::bind(&Timer::TimerThreadProc)); l_Thread = boost::thread(boost::bind(&Timer::TimerThreadProc));
} }
/** /**
@ -75,12 +98,12 @@ void Timer::Initialize(void)
void Timer::Uninitialize(void) void Timer::Uninitialize(void)
{ {
{ {
boost::mutex::scoped_lock lock(m_Mutex); boost::mutex::scoped_lock lock(l_Mutex);
m_StopThread = true; l_StopThread = true;
m_CV.notify_all(); l_CV.notify_all();
} }
m_Thread.join(); l_Thread.join();
} }
/** /**
@ -109,7 +132,7 @@ void Timer::SetInterval(double interval)
{ {
ASSERT(!OwnsLock()); ASSERT(!OwnsLock());
boost::mutex::scoped_lock lock(m_Mutex); boost::mutex::scoped_lock lock(l_Mutex);
m_Interval = interval; m_Interval = interval;
} }
@ -123,7 +146,7 @@ double Timer::GetInterval(void) const
{ {
ASSERT(!OwnsLock()); ASSERT(!OwnsLock());
boost::mutex::scoped_lock lock(m_Mutex); boost::mutex::scoped_lock lock(l_Mutex);
return m_Interval; return m_Interval;
} }
@ -137,7 +160,7 @@ void Timer::Start(void)
ASSERT(!OwnsLock()); ASSERT(!OwnsLock());
{ {
boost::mutex::scoped_lock lock(m_Mutex); boost::mutex::scoped_lock lock(l_Mutex);
m_Started = true; m_Started = true;
} }
@ -153,13 +176,13 @@ void Timer::Stop(void)
{ {
ASSERT(!OwnsLock()); ASSERT(!OwnsLock());
boost::mutex::scoped_lock lock(m_Mutex); boost::mutex::scoped_lock lock(l_Mutex);
m_Started = false; m_Started = false;
m_Timers.erase(GetSelf()); l_Timers.erase(GetSelf());
/* Notify the worker thread that we've disabled a timer. */ /* Notify the worker thread that we've disabled a timer. */
m_CV.notify_all(); l_CV.notify_all();
} }
/** /**
@ -173,7 +196,7 @@ void Timer::Reschedule(double next)
{ {
ASSERT(!OwnsLock()); ASSERT(!OwnsLock());
boost::mutex::scoped_lock lock(m_Mutex); boost::mutex::scoped_lock lock(l_Mutex);
if (next < 0) if (next < 0)
next = Utility::GetTime() + m_Interval; next = Utility::GetTime() + m_Interval;
@ -182,11 +205,11 @@ void Timer::Reschedule(double next)
if (m_Started) { if (m_Started) {
/* Remove and re-add the timer to update the index. */ /* Remove and re-add the timer to update the index. */
m_Timers.erase(GetSelf()); l_Timers.erase(GetSelf());
m_Timers.insert(GetSelf()); l_Timers.insert(GetSelf());
/* Notify the worker that we've rescheduled a timer. */ /* Notify the worker that we've rescheduled a timer. */
m_CV.notify_all(); l_CV.notify_all();
} }
} }
@ -200,7 +223,7 @@ double Timer::GetNext(void) const
{ {
ASSERT(!OwnsLock()); ASSERT(!OwnsLock());
boost::mutex::scoped_lock lock(m_Mutex); boost::mutex::scoped_lock lock(l_Mutex);
return m_Next; return m_Next;
} }
@ -213,12 +236,12 @@ double Timer::GetNext(void) const
*/ */
void Timer::AdjustTimers(double adjustment) void Timer::AdjustTimers(double adjustment)
{ {
boost::mutex::scoped_lock lock(m_Mutex); boost::mutex::scoped_lock lock(l_Mutex);
double now = Utility::GetTime(); double now = Utility::GetTime();
typedef boost::multi_index::nth_index<TimerSet, 1>::type TimerView; typedef boost::multi_index::nth_index<TimerSet, 1>::type TimerView;
TimerView& idx = boost::get<1>(m_Timers); TimerView& idx = boost::get<1>(l_Timers);
TimerView::iterator it; TimerView::iterator it;
for (it = idx.begin(); it != idx.end(); it++) { for (it = idx.begin(); it != idx.end(); it++) {
@ -227,13 +250,13 @@ void Timer::AdjustTimers(double adjustment)
if (abs(now - (timer->m_Next + adjustment)) < if (abs(now - (timer->m_Next + adjustment)) <
abs(now - timer->m_Next)) { abs(now - timer->m_Next)) {
timer->m_Next += adjustment; timer->m_Next += adjustment;
m_Timers.erase(timer); l_Timers.erase(timer);
m_Timers.insert(timer); l_Timers.insert(timer);
} }
} }
/* Notify the worker that we've rescheduled some timers. */ /* Notify the worker that we've rescheduled some timers. */
m_CV.notify_all(); l_CV.notify_all();
} }
/** /**
@ -244,16 +267,16 @@ void Timer::AdjustTimers(double adjustment)
void Timer::TimerThreadProc(void) void Timer::TimerThreadProc(void)
{ {
for (;;) { for (;;) {
boost::mutex::scoped_lock lock(m_Mutex); boost::mutex::scoped_lock lock(l_Mutex);
typedef boost::multi_index::nth_index<TimerSet, 1>::type NextTimerView; typedef boost::multi_index::nth_index<TimerSet, 1>::type NextTimerView;
NextTimerView& idx = boost::get<1>(m_Timers); NextTimerView& idx = boost::get<1>(l_Timers);
/* Wait until there is at least one timer. */ /* Wait until there is at least one timer. */
while (idx.empty() && !m_StopThread) while (idx.empty() && !l_StopThread)
m_CV.wait(lock); l_CV.wait(lock);
if (m_StopThread) if (l_StopThread)
break; break;
NextTimerView::iterator it = idx.begin(); NextTimerView::iterator it = idx.begin();
@ -272,14 +295,14 @@ void Timer::TimerThreadProc(void)
timer.reset(); timer.reset();
/* Wait for the next timer. */ /* Wait for the next timer. */
m_CV.timed_wait(lock, boost::posix_time::milliseconds(wait * 1000)); l_CV.timed_wait(lock, boost::posix_time::milliseconds(wait * 1000));
continue; continue;
} }
/* Remove the timer from the list so it doesn't get called again /* Remove the timer from the list so it doesn't get called again
* until the current call is completed. */ * until the current call is completed. */
m_Timers.erase(timer); l_Timers.erase(timer);
lock.unlock(); lock.unlock();

View File

@ -22,28 +22,11 @@
#include "base/i2-base.h" #include "base/i2-base.h"
#include "base/object.h" #include "base/object.h"
#include <list>
#include <boost/thread/thread.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/condition_variable.hpp>
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/ordered_index.hpp>
#include <boost/multi_index/key_extractors.hpp>
#include <boost/signals2.hpp> #include <boost/signals2.hpp>
namespace icinga { namespace icinga {
class Timer; struct TimerNextExtractor;
/**
* @ingroup base
*/
struct TimerNextExtractor
{
typedef double result_type;
double operator()(const weak_ptr<Timer>& wtimer);
};
/** /**
* A timer that periodically triggers an event. * A timer that periodically triggers an event.
@ -56,8 +39,6 @@ public:
typedef shared_ptr<Timer> Ptr; typedef shared_ptr<Timer> Ptr;
typedef weak_ptr<Timer> WeakPtr; typedef weak_ptr<Timer> WeakPtr;
typedef std::list<Timer::WeakPtr> CollectionType;
Timer(void); Timer(void);
void SetInterval(double interval); void SetInterval(double interval);
@ -81,20 +62,6 @@ private:
double m_Next; /**< When the next event should happen. */ double m_Next; /**< When the next event should happen. */
bool m_Started; /**< Whether the timer is enabled. */ bool m_Started; /**< Whether the timer is enabled. */
typedef boost::multi_index_container<
Timer::WeakPtr,
boost::multi_index::indexed_by<
boost::multi_index::ordered_unique<boost::multi_index::identity<Timer::WeakPtr> >,
boost::multi_index::ordered_non_unique<TimerNextExtractor>
>
> TimerSet;
static boost::mutex m_Mutex;
static boost::condition_variable m_CV;
static boost::thread m_Thread;
static bool m_StopThread;
static TimerSet m_Timers;
void Call(); void Call();
static void TimerThreadProc(void); static void TimerThreadProc(void);

View File

@ -29,7 +29,6 @@
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <pthread.h>
#include <libgen.h> #include <libgen.h>
#include <syslog.h> #include <syslog.h>
#include <sys/file.h> #include <sys/file.h>

View File

@ -20,6 +20,7 @@
#include "base/application.h" #include "base/application.h"
#include "base/array.h" #include "base/array.h"
#include "base/logger_fwd.h" #include "base/logger_fwd.h"
#include "base/utility.h"
#include <cJSON.h> #include <cJSON.h>
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>

File diff suppressed because it is too large Load Diff

View File

@ -55,16 +55,30 @@
******************************************************************************/ ******************************************************************************/
#include "i2-config.h" #include "i2-config.h"
#include "config/expression.h"
#include "config/expressionlist.h"
#include "config/configitembuilder.h"
#include "config/configcompiler.h"
#include "config/configcompilercontext.h"
#include "config/typerule.h"
#include "config/typerulelist.h"
#include "base/value.h"
#include "base/utility.h"
#include "base/array.h"
#include <sstream>
#include <stack>
#include <boost/smart_ptr/make_shared.hpp>
#include <boost/exception/diagnostic_information.hpp>
using namespace icinga; using namespace icinga;
#define YYLTYPE DebugInfo #define YYLTYPE icinga::DebugInfo
/* Line 2068 of yacc.c */ /* Line 2068 of yacc.c */
#line 68 "config_parser.h" #line 82 "config_parser.h"
/* Tokens. */ /* Tokens. */
#ifndef YYTOKENTYPE #ifndef YYTOKENTYPE
@ -140,7 +154,7 @@ typedef union YYSTYPE
{ {
/* Line 2068 of yacc.c */ /* Line 2068 of yacc.c */
#line 38 "config_parser.yy" #line 52 "config_parser.yy"
char *text; char *text;
double num; double num;
@ -151,7 +165,7 @@ typedef union YYSTYPE
/* Line 2068 of yacc.c */ /* Line 2068 of yacc.c */
#line 155 "config_parser.h" #line 169 "config_parser.h"
} YYSTYPE; } YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define yystype YYSTYPE /* obsolescent; will be withdrawn */

View File

@ -27,10 +27,12 @@
#include "config/typerule.h" #include "config/typerule.h"
#include "config/typerulelist.h" #include "config/typerulelist.h"
#include "base/value.h" #include "base/value.h"
#include "base/utility.h"
#include "base/array.h" #include "base/array.h"
#include <sstream> #include <sstream>
#include <stack> #include <stack>
#include <boost/smart_ptr/make_shared.hpp> #include <boost/smart_ptr/make_shared.hpp>
#include <boost/exception/diagnostic_information.hpp>
using namespace icinga; using namespace icinga;

View File

@ -22,6 +22,7 @@
#include "base/dynamictype.h" #include "base/dynamictype.h"
#include "base/objectlock.h" #include "base/objectlock.h"
#include "base/logger_fwd.h" #include "base/logger_fwd.h"
#include "base/utility.h"
#include <sstream> #include <sstream>
#include <boost/tuple/tuple.hpp> #include <boost/tuple/tuple.hpp>
#include <boost/smart_ptr/make_shared.hpp> #include <boost/smart_ptr/make_shared.hpp>

View File

@ -21,6 +21,7 @@
#include "config/configcompilercontext.h" #include "config/configcompilercontext.h"
#include "base/objectlock.h" #include "base/objectlock.h"
#include "base/convert.h" #include "base/convert.h"
#include "base/scripttask.h"
#include <boost/tuple/tuple.hpp> #include <boost/tuple/tuple.hpp>
#include <boost/smart_ptr/make_shared.hpp> #include <boost/smart_ptr/make_shared.hpp>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>

View File

@ -22,6 +22,7 @@
#include "config/i2-config.h" #include "config/i2-config.h"
#include "base/value.h" #include "base/value.h"
#include <vector>
namespace icinga namespace icinga
{ {

View File

@ -32,6 +32,7 @@
#include <boost/algorithm/string/classification.hpp> #include <boost/algorithm/string/classification.hpp>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <boost/exception/diagnostic_information.hpp> #include <boost/exception/diagnostic_information.hpp>
#include <boost/algorithm/string/split.hpp>
using namespace icinga; using namespace icinga;
@ -63,7 +64,8 @@ void ExternalCommandProcessor::Execute(const String& line)
if (ts == 0) if (ts == 0)
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid timestamp in command: " + line)); BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid timestamp in command: " + line));
std::vector<String> argv = args.Split(boost::is_any_of(";")); std::vector<String> argv;
boost::algorithm::split(argv, args, boost::is_any_of(";"));
if (argv.empty()) if (argv.empty())
BOOST_THROW_EXCEPTION(std::invalid_argument("Missing arguments in command: " + line)); BOOST_THROW_EXCEPTION(std::invalid_argument("Missing arguments in command: " + line));

View File

@ -22,9 +22,10 @@
#include "icinga/i2-icinga.h" #include "icinga/i2-icinga.h"
#include "base/qstring.h" #include "base/qstring.h"
#include <vector>
#include <boost/thread/mutex.hpp> #include <boost/thread/mutex.hpp>
#include <boost/thread/once.hpp> #include <boost/thread/once.hpp>
#include <boost/function.hpp>
#include <vector>
namespace icinga namespace icinga
{ {

View File

@ -23,6 +23,7 @@
#include "base/dynamictype.h" #include "base/dynamictype.h"
#include "base/objectlock.h" #include "base/objectlock.h"
#include "base/logger_fwd.h" #include "base/logger_fwd.h"
#include "base/timer.h"
#include "config/configitembuilder.h" #include "config/configitembuilder.h"
#include "config/configcompilercontext.h" #include "config/configcompilercontext.h"
#include <boost/tuple/tuple.hpp> #include <boost/tuple/tuple.hpp>
@ -31,10 +32,10 @@
using namespace icinga; using namespace icinga;
boost::mutex Host::m_ServiceMutex; static boost::mutex l_ServiceMutex;
std::map<String, std::map<String, Service::WeakPtr> > Host::m_ServicesCache; static std::map<String, std::map<String, Service::WeakPtr> > l_ServicesCache;
bool Host::m_ServicesCacheNeedsUpdate = false; static bool l_ServicesCacheNeedsUpdate = false;
Timer::Ptr Host::m_ServicesCacheTimer; static Timer::Ptr l_ServicesCacheTimer;
REGISTER_SCRIPTFUNCTION(ValidateServiceDictionary, &Host::ValidateServiceDictionary); REGISTER_SCRIPTFUNCTION(ValidateServiceDictionary, &Host::ValidateServiceDictionary);
@ -313,10 +314,10 @@ std::set<Service::Ptr> Host::GetServices(void) const
{ {
std::set<Service::Ptr> services; std::set<Service::Ptr> services;
boost::mutex::scoped_lock lock(m_ServiceMutex); boost::mutex::scoped_lock lock(l_ServiceMutex);
Service::WeakPtr wservice; Service::WeakPtr wservice;
BOOST_FOREACH(boost::tie(boost::tuples::ignore, wservice), m_ServicesCache[GetName()]) { BOOST_FOREACH(boost::tie(boost::tuples::ignore, wservice), l_ServicesCache[GetName()]) {
Service::Ptr service = wservice.lock(); Service::Ptr service = wservice.lock();
if (!service) if (!service)
@ -331,31 +332,31 @@ std::set<Service::Ptr> Host::GetServices(void) const
void Host::InvalidateServicesCache(void) void Host::InvalidateServicesCache(void)
{ {
{ {
boost::mutex::scoped_lock lock(m_ServiceMutex); boost::mutex::scoped_lock lock(l_ServiceMutex);
if (m_ServicesCacheNeedsUpdate) if (l_ServicesCacheNeedsUpdate)
return; /* Someone else has already requested a refresh. */ return; /* Someone else has already requested a refresh. */
if (!m_ServicesCacheTimer) { if (!l_ServicesCacheTimer) {
m_ServicesCacheTimer = boost::make_shared<Timer>(); l_ServicesCacheTimer = boost::make_shared<Timer>();
m_ServicesCacheTimer->SetInterval(0.5); l_ServicesCacheTimer->SetInterval(0.5);
m_ServicesCacheTimer->OnTimerExpired.connect(boost::bind(&Host::RefreshServicesCache)); l_ServicesCacheTimer->OnTimerExpired.connect(boost::bind(&Host::RefreshServicesCache));
m_ServicesCacheTimer->Start(); l_ServicesCacheTimer->Start();
} }
m_ServicesCacheNeedsUpdate = true; l_ServicesCacheNeedsUpdate = true;
} }
} }
void Host::RefreshServicesCache(void) void Host::RefreshServicesCache(void)
{ {
{ {
boost::mutex::scoped_lock lock(m_ServiceMutex); boost::mutex::scoped_lock lock(l_ServiceMutex);
if (!m_ServicesCacheNeedsUpdate) if (!l_ServicesCacheNeedsUpdate)
return; return;
m_ServicesCacheNeedsUpdate = false; l_ServicesCacheNeedsUpdate = false;
} }
Log(LogDebug, "icinga", "Updating Host services cache."); Log(LogDebug, "icinga", "Updating Host services cache.");
@ -375,8 +376,8 @@ void Host::RefreshServicesCache(void)
newServicesCache[host->GetName()][service->GetShortName()] = service; newServicesCache[host->GetName()][service->GetShortName()] = service;
} }
boost::mutex::scoped_lock lock(m_ServiceMutex); boost::mutex::scoped_lock lock(l_ServiceMutex);
m_ServicesCache.swap(newServicesCache); l_ServicesCache.swap(newServicesCache);
} }
void Host::ValidateServiceDictionary(const ScriptTask::Ptr& task, const std::vector<Value>& arguments) void Host::ValidateServiceDictionary(const ScriptTask::Ptr& task, const std::vector<Value>& arguments)
@ -438,9 +439,9 @@ Service::Ptr Host::GetServiceByShortName(const Value& name) const
{ {
if (name.IsScalar()) { if (name.IsScalar()) {
{ {
boost::mutex::scoped_lock lock(m_ServiceMutex); boost::mutex::scoped_lock lock(l_ServiceMutex);
std::map<String, Service::WeakPtr>& services = m_ServicesCache[GetName()]; std::map<String, Service::WeakPtr>& services = l_ServicesCache[GetName()];
std::map<String, Service::WeakPtr>::iterator it = services.find(name); std::map<String, Service::WeakPtr>::iterator it = services.find(name);
if (it != services.end()) { if (it != services.end()) {

View File

@ -114,11 +114,6 @@ private:
Attribute<String> m_HostCheck; Attribute<String> m_HostCheck;
Dictionary::Ptr m_SlaveServices; Dictionary::Ptr m_SlaveServices;
static boost::mutex m_ServiceMutex;
static std::map<String, std::map<String, weak_ptr<Service> > > m_ServicesCache;
static bool m_ServicesCacheNeedsUpdate;
static Timer::Ptr m_ServicesCacheTimer;
void UpdateSlaveServices(void); void UpdateSlaveServices(void);
static void RefreshServicesCache(void); static void RefreshServicesCache(void);

View File

@ -21,15 +21,16 @@
#include "base/dynamictype.h" #include "base/dynamictype.h"
#include "base/logger_fwd.h" #include "base/logger_fwd.h"
#include "base/objectlock.h" #include "base/objectlock.h"
#include "base/timer.h"
#include <boost/smart_ptr/make_shared.hpp> #include <boost/smart_ptr/make_shared.hpp>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
using namespace icinga; using namespace icinga;
boost::mutex HostGroup::m_Mutex; static boost::mutex l_Mutex;
std::map<String, std::vector<Host::WeakPtr> > HostGroup::m_MembersCache; static std::map<String, std::vector<Host::WeakPtr> > l_MembersCache;
bool HostGroup::m_MembersCacheNeedsUpdate = false; static bool l_MembersCacheNeedsUpdate = false;
Timer::Ptr HostGroup::m_MembersCacheTimer; static Timer::Ptr l_MembersCacheTimer;
REGISTER_TYPE(HostGroup); REGISTER_TYPE(HostGroup);
@ -104,9 +105,9 @@ std::set<Host::Ptr> HostGroup::GetMembers(void) const
std::set<Host::Ptr> hosts; std::set<Host::Ptr> hosts;
{ {
boost::mutex::scoped_lock lock(m_Mutex); boost::mutex::scoped_lock lock(l_Mutex);
BOOST_FOREACH(const Host::WeakPtr& whost, m_MembersCache[GetName()]) { BOOST_FOREACH(const Host::WeakPtr& whost, l_MembersCache[GetName()]) {
Host::Ptr host = whost.lock(); Host::Ptr host = whost.lock();
if (!host) if (!host)
@ -124,19 +125,19 @@ std::set<Host::Ptr> HostGroup::GetMembers(void) const
*/ */
void HostGroup::InvalidateMembersCache(void) void HostGroup::InvalidateMembersCache(void)
{ {
boost::mutex::scoped_lock lock(m_Mutex); boost::mutex::scoped_lock lock(l_Mutex);
if (m_MembersCacheNeedsUpdate) if (l_MembersCacheNeedsUpdate)
return; /* Someone else has already requested a refresh. */ return; /* Someone else has already requested a refresh. */
if (!m_MembersCacheTimer) { if (!l_MembersCacheTimer) {
m_MembersCacheTimer = boost::make_shared<Timer>(); l_MembersCacheTimer = boost::make_shared<Timer>();
m_MembersCacheTimer->SetInterval(0.5); l_MembersCacheTimer->SetInterval(0.5);
m_MembersCacheTimer->OnTimerExpired.connect(boost::bind(&HostGroup::RefreshMembersCache)); l_MembersCacheTimer->OnTimerExpired.connect(boost::bind(&HostGroup::RefreshMembersCache));
m_MembersCacheTimer->Start(); l_MembersCacheTimer->Start();
} }
m_MembersCacheNeedsUpdate = true; l_MembersCacheNeedsUpdate = true;
} }
/** /**
@ -145,12 +146,12 @@ void HostGroup::InvalidateMembersCache(void)
void HostGroup::RefreshMembersCache(void) void HostGroup::RefreshMembersCache(void)
{ {
{ {
boost::mutex::scoped_lock lock(m_Mutex); boost::mutex::scoped_lock lock(l_Mutex);
if (!m_MembersCacheNeedsUpdate) if (!l_MembersCacheNeedsUpdate)
return; return;
m_MembersCacheNeedsUpdate = false; l_MembersCacheNeedsUpdate = false;
} }
Log(LogDebug, "icinga", "Updating HostGroup members cache."); Log(LogDebug, "icinga", "Updating HostGroup members cache.");
@ -171,6 +172,6 @@ void HostGroup::RefreshMembersCache(void)
} }
} }
boost::mutex::scoped_lock lock(m_Mutex); boost::mutex::scoped_lock lock(l_Mutex);
m_MembersCache.swap(newMembersCache); l_MembersCache.swap(newMembersCache);
} }

View File

@ -60,11 +60,6 @@ private:
Attribute<String> m_NotesUrl; Attribute<String> m_NotesUrl;
Attribute<String> m_ActionUrl; Attribute<String> m_ActionUrl;
static boost::mutex m_Mutex;
static std::map<String, std::vector<Host::WeakPtr> > m_MembersCache;
static bool m_MembersCacheNeedsUpdate;
static Timer::Ptr m_MembersCacheTimer;
static void RefreshMembersCache(void); static void RefreshMembersCache(void);
}; };

View File

@ -22,10 +22,13 @@
#include "base/dynamictype.h" #include "base/dynamictype.h"
#include "base/logger_fwd.h" #include "base/logger_fwd.h"
#include "base/objectlock.h" #include "base/objectlock.h"
#include "base/timer.h"
#include <boost/smart_ptr/make_shared.hpp> #include <boost/smart_ptr/make_shared.hpp>
using namespace icinga; using namespace icinga;
static Timer::Ptr l_RetentionTimer;
REGISTER_TYPE(IcingaApplication); REGISTER_TYPE(IcingaApplication);
#ifndef _WIN32 #ifndef _WIN32
@ -78,10 +81,10 @@ int IcingaApplication::Main(void)
DynamicObject::RestoreObjects(GetStatePath()); DynamicObject::RestoreObjects(GetStatePath());
/* periodically dump the program state */ /* periodically dump the program state */
m_RetentionTimer = boost::make_shared<Timer>(); l_RetentionTimer = boost::make_shared<Timer>();
m_RetentionTimer->SetInterval(300); l_RetentionTimer->SetInterval(300);
m_RetentionTimer->OnTimerExpired.connect(boost::bind(&IcingaApplication::DumpProgramState, this)); l_RetentionTimer->OnTimerExpired.connect(boost::bind(&IcingaApplication::DumpProgramState, this));
m_RetentionTimer->Start(); l_RetentionTimer->Start();
RunEventLoop(); RunEventLoop();
@ -99,7 +102,7 @@ void IcingaApplication::OnShutdown(void)
{ {
ObjectLock olock(this); ObjectLock olock(this);
m_RetentionTimer->Stop(); l_RetentionTimer->Stop();
} }
DumpProgramState(); DumpProgramState();

View File

@ -69,8 +69,6 @@ private:
double m_StartTime; double m_StartTime;
Timer::Ptr m_RetentionTimer;
void DumpProgramState(void); void DumpProgramState(void);
virtual void OnShutdown(void); virtual void OnShutdown(void);

View File

@ -23,6 +23,7 @@
#include "icinga/i2-icinga.h" #include "icinga/i2-icinga.h"
#include "remoting/endpoint.h" #include "remoting/endpoint.h"
#include "base/dynamicobject.h" #include "base/dynamicobject.h"
#include "base/timer.h"
#include <fstream> #include <fstream>
namespace icinga namespace icinga

View File

@ -21,6 +21,7 @@
#include "icinga/macroprocessor.h" #include "icinga/macroprocessor.h"
#include "base/dynamictype.h" #include "base/dynamictype.h"
#include <boost/algorithm/string/classification.hpp> #include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/smart_ptr/make_shared.hpp> #include <boost/smart_ptr/make_shared.hpp>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
@ -109,7 +110,8 @@ Dictionary::Ptr PluginCheckTask::ParseCheckOutput(const String& output)
String text; String text;
String perfdata; String perfdata;
std::vector<String> lines = output.Split(boost::is_any_of("\r\n")); std::vector<String> lines;
boost::algorithm::split(lines, output, boost::is_any_of("\r\n"));
BOOST_FOREACH (const String& line, lines) { BOOST_FOREACH (const String& line, lines) {
size_t delim = line.FindFirstOf("|"); size_t delim = line.FindFirstOf("|");

View File

@ -21,27 +21,29 @@
#include "base/dynamictype.h" #include "base/dynamictype.h"
#include "base/objectlock.h" #include "base/objectlock.h"
#include "base/logger_fwd.h" #include "base/logger_fwd.h"
#include "base/timer.h"
#include <boost/smart_ptr/make_shared.hpp> #include <boost/smart_ptr/make_shared.hpp>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <boost/tuple/tuple.hpp>
using namespace icinga; using namespace icinga;
int Service::m_NextCommentID = 1; static int l_NextCommentID = 1;
boost::mutex Service::m_CommentMutex; static boost::mutex l_CommentMutex;
std::map<int, String> Service::m_LegacyCommentsCache; static std::map<int, String> l_LegacyCommentsCache;
std::map<String, Service::WeakPtr> Service::m_CommentsCache; static std::map<String, Service::WeakPtr> l_CommentsCache;
bool Service::m_CommentsCacheNeedsUpdate = false; static bool l_CommentsCacheNeedsUpdate = false;
Timer::Ptr Service::m_CommentsCacheTimer; static Timer::Ptr l_CommentsCacheTimer;
Timer::Ptr Service::m_CommentsExpireTimer; static Timer::Ptr l_CommentsExpireTimer;
/** /**
* @threadsafety Always. * @threadsafety Always.
*/ */
int Service::GetNextCommentID(void) int Service::GetNextCommentID(void)
{ {
boost::mutex::scoped_lock lock(m_CommentMutex); boost::mutex::scoped_lock lock(l_CommentMutex);
return m_NextCommentID; return l_NextCommentID;
} }
/** /**
@ -68,8 +70,8 @@ String Service::AddComment(CommentType entryType, const String& author,
int legacy_id; int legacy_id;
{ {
boost::mutex::scoped_lock lock(m_CommentMutex); boost::mutex::scoped_lock lock(l_CommentMutex);
legacy_id = m_NextCommentID++; legacy_id = l_NextCommentID++;
} }
comment->Set("legacy_id", legacy_id); comment->Set("legacy_id", legacy_id);
@ -127,11 +129,11 @@ void Service::RemoveComment(const String& id)
*/ */
String Service::GetCommentIDFromLegacyID(int id) String Service::GetCommentIDFromLegacyID(int id)
{ {
boost::mutex::scoped_lock lock(m_CommentMutex); boost::mutex::scoped_lock lock(l_CommentMutex);
std::map<int, String>::iterator it = m_LegacyCommentsCache.find(id); std::map<int, String>::iterator it = l_LegacyCommentsCache.find(id);
if (it == m_LegacyCommentsCache.end()) if (it == l_LegacyCommentsCache.end())
return Empty; return Empty;
return it->second; return it->second;
@ -142,9 +144,9 @@ String Service::GetCommentIDFromLegacyID(int id)
*/ */
Service::Ptr Service::GetOwnerByCommentID(const String& id) Service::Ptr Service::GetOwnerByCommentID(const String& id)
{ {
boost::mutex::scoped_lock lock(m_CommentMutex); boost::mutex::scoped_lock lock(l_CommentMutex);
return m_CommentsCache[id].lock(); return l_CommentsCache[id].lock();
} }
/** /**
@ -180,19 +182,19 @@ bool Service::IsCommentExpired(const Dictionary::Ptr& comment)
*/ */
void Service::InvalidateCommentsCache(void) void Service::InvalidateCommentsCache(void)
{ {
boost::mutex::scoped_lock lock(m_CommentMutex); boost::mutex::scoped_lock lock(l_CommentMutex);
if (m_CommentsCacheNeedsUpdate) if (l_CommentsCacheNeedsUpdate)
return; /* Someone else has already requested a refresh. */ return; /* Someone else has already requested a refresh. */
if (!m_CommentsCacheTimer) { if (!l_CommentsCacheTimer) {
m_CommentsCacheTimer = boost::make_shared<Timer>(); l_CommentsCacheTimer = boost::make_shared<Timer>();
m_CommentsCacheTimer->SetInterval(0.5); l_CommentsCacheTimer->SetInterval(0.5);
m_CommentsCacheTimer->OnTimerExpired.connect(boost::bind(&Service::RefreshCommentsCache)); l_CommentsCacheTimer->OnTimerExpired.connect(boost::bind(&Service::RefreshCommentsCache));
m_CommentsCacheTimer->Start(); l_CommentsCacheTimer->Start();
} }
m_CommentsCacheNeedsUpdate = true; l_CommentsCacheNeedsUpdate = true;
} }
/** /**
@ -201,12 +203,12 @@ void Service::InvalidateCommentsCache(void)
void Service::RefreshCommentsCache(void) void Service::RefreshCommentsCache(void)
{ {
{ {
boost::mutex::scoped_lock lock(m_CommentMutex); boost::mutex::scoped_lock lock(l_CommentMutex);
if (!m_CommentsCacheNeedsUpdate) if (!l_CommentsCacheNeedsUpdate)
return; return;
m_CommentsCacheNeedsUpdate = false; l_CommentsCacheNeedsUpdate = false;
} }
Log(LogDebug, "icinga", "Updating Service comments cache."); Log(LogDebug, "icinga", "Updating Service comments cache.");
@ -229,14 +231,14 @@ void Service::RefreshCommentsCache(void)
BOOST_FOREACH(tie(id, comment), comments) { BOOST_FOREACH(tie(id, comment), comments) {
int legacy_id = comment->Get("legacy_id"); int legacy_id = comment->Get("legacy_id");
if (legacy_id >= m_NextCommentID) if (legacy_id >= l_NextCommentID)
m_NextCommentID = legacy_id + 1; l_NextCommentID = legacy_id + 1;
if (newLegacyCommentsCache.find(legacy_id) != newLegacyCommentsCache.end()) { if (newLegacyCommentsCache.find(legacy_id) != newLegacyCommentsCache.end()) {
/* The legacy_id is already in use by another comment; /* The legacy_id is already in use by another comment;
* this shouldn't usually happen - assign it a new ID */ * this shouldn't usually happen - assign it a new ID */
legacy_id = m_NextCommentID++; legacy_id = l_NextCommentID++;
comment->Set("legacy_id", legacy_id); comment->Set("legacy_id", legacy_id);
service->Touch("comments"); service->Touch("comments");
} }
@ -246,16 +248,16 @@ void Service::RefreshCommentsCache(void)
} }
} }
boost::mutex::scoped_lock lock(m_CommentMutex); boost::mutex::scoped_lock lock(l_CommentMutex);
m_CommentsCache.swap(newCommentsCache); l_CommentsCache.swap(newCommentsCache);
m_LegacyCommentsCache.swap(newLegacyCommentsCache); l_LegacyCommentsCache.swap(newLegacyCommentsCache);
if (!m_CommentsExpireTimer) { if (!l_CommentsExpireTimer) {
m_CommentsExpireTimer = boost::make_shared<Timer>(); l_CommentsExpireTimer = boost::make_shared<Timer>();
m_CommentsExpireTimer->SetInterval(300); l_CommentsExpireTimer->SetInterval(300);
m_CommentsExpireTimer->OnTimerExpired.connect(boost::bind(&Service::CommentsExpireTimerHandler)); l_CommentsExpireTimer->OnTimerExpired.connect(boost::bind(&Service::CommentsExpireTimerHandler));
m_CommentsExpireTimer->Start(); l_CommentsExpireTimer->Start();
} }
} }

View File

@ -21,28 +21,29 @@
#include "base/dynamictype.h" #include "base/dynamictype.h"
#include "base/objectlock.h" #include "base/objectlock.h"
#include "base/logger_fwd.h" #include "base/logger_fwd.h"
#include "base/timer.h"
#include <boost/tuple/tuple.hpp> #include <boost/tuple/tuple.hpp>
#include <boost/smart_ptr/make_shared.hpp> #include <boost/smart_ptr/make_shared.hpp>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
using namespace icinga; using namespace icinga;
int Service::m_NextDowntimeID = 1; static int l_NextDowntimeID = 1;
boost::mutex Service::m_DowntimeMutex; static boost::mutex l_DowntimeMutex;
std::map<int, String> Service::m_LegacyDowntimesCache; static std::map<int, String> l_LegacyDowntimesCache;
std::map<String, Service::WeakPtr> Service::m_DowntimesCache; static std::map<String, Service::WeakPtr> l_DowntimesCache;
bool Service::m_DowntimesCacheNeedsUpdate = false; static bool l_DowntimesCacheNeedsUpdate = false;
Timer::Ptr Service::m_DowntimesCacheTimer; static Timer::Ptr l_DowntimesCacheTimer;
Timer::Ptr Service::m_DowntimesExpireTimer; static Timer::Ptr l_DowntimesExpireTimer;
/** /**
* @threadsafety Always. * @threadsafety Always.
*/ */
int Service::GetNextDowntimeID(void) int Service::GetNextDowntimeID(void)
{ {
boost::mutex::scoped_lock lock(m_DowntimeMutex); boost::mutex::scoped_lock lock(l_DowntimeMutex);
return m_NextDowntimeID; return l_NextDowntimeID;
} }
/** /**
@ -75,8 +76,8 @@ String Service::AddDowntime(const String& author, const String& comment,
int legacy_id; int legacy_id;
{ {
boost::mutex::scoped_lock lock(m_DowntimeMutex); boost::mutex::scoped_lock lock(l_DowntimeMutex);
legacy_id = m_NextDowntimeID++; legacy_id = l_NextDowntimeID++;
} }
downtime->Set("legacy_id", legacy_id); downtime->Set("legacy_id", legacy_id);
@ -183,11 +184,11 @@ void Service::TriggerDowntime(const String& id)
*/ */
String Service::GetDowntimeIDFromLegacyID(int id) String Service::GetDowntimeIDFromLegacyID(int id)
{ {
boost::mutex::scoped_lock lock(m_DowntimeMutex); boost::mutex::scoped_lock lock(l_DowntimeMutex);
std::map<int, String>::iterator it = m_LegacyDowntimesCache.find(id); std::map<int, String>::iterator it = l_LegacyDowntimesCache.find(id);
if (it == m_LegacyDowntimesCache.end()) if (it == l_LegacyDowntimesCache.end())
return Empty; return Empty;
return it->second; return it->second;
@ -198,8 +199,8 @@ String Service::GetDowntimeIDFromLegacyID(int id)
*/ */
Service::Ptr Service::GetOwnerByDowntimeID(const String& id) Service::Ptr Service::GetOwnerByDowntimeID(const String& id)
{ {
boost::mutex::scoped_lock lock(m_DowntimeMutex); boost::mutex::scoped_lock lock(l_DowntimeMutex);
return m_DowntimesCache[id].lock(); return l_DowntimesCache[id].lock();
} }
/** /**
@ -255,19 +256,19 @@ bool Service::IsDowntimeExpired(const Dictionary::Ptr& downtime)
*/ */
void Service::InvalidateDowntimesCache(void) void Service::InvalidateDowntimesCache(void)
{ {
boost::mutex::scoped_lock lock(m_DowntimeMutex); boost::mutex::scoped_lock lock(l_DowntimeMutex);
if (m_DowntimesCacheNeedsUpdate) if (l_DowntimesCacheNeedsUpdate)
return; /* Someone else has already requested a refresh. */ return; /* Someone else has already requested a refresh. */
if (!m_DowntimesCacheTimer) { if (!l_DowntimesCacheTimer) {
m_DowntimesCacheTimer = boost::make_shared<Timer>(); l_DowntimesCacheTimer = boost::make_shared<Timer>();
m_DowntimesCacheTimer->SetInterval(0.5); l_DowntimesCacheTimer->SetInterval(0.5);
m_DowntimesCacheTimer->OnTimerExpired.connect(boost::bind(&Service::RefreshDowntimesCache)); l_DowntimesCacheTimer->OnTimerExpired.connect(boost::bind(&Service::RefreshDowntimesCache));
m_DowntimesCacheTimer->Start(); l_DowntimesCacheTimer->Start();
} }
m_DowntimesCacheNeedsUpdate = true; l_DowntimesCacheNeedsUpdate = true;
} }
/** /**
@ -276,12 +277,12 @@ void Service::InvalidateDowntimesCache(void)
void Service::RefreshDowntimesCache(void) void Service::RefreshDowntimesCache(void)
{ {
{ {
boost::mutex::scoped_lock lock(m_DowntimeMutex); boost::mutex::scoped_lock lock(l_DowntimeMutex);
if (!m_DowntimesCacheNeedsUpdate) if (!l_DowntimesCacheNeedsUpdate)
return; return;
m_DowntimesCacheNeedsUpdate = false; l_DowntimesCacheNeedsUpdate = false;
} }
Log(LogDebug, "icinga", "Updating Service downtimes cache."); Log(LogDebug, "icinga", "Updating Service downtimes cache.");
@ -304,13 +305,13 @@ void Service::RefreshDowntimesCache(void)
BOOST_FOREACH(boost::tie(id, downtime), downtimes) { BOOST_FOREACH(boost::tie(id, downtime), downtimes) {
int legacy_id = downtime->Get("legacy_id"); int legacy_id = downtime->Get("legacy_id");
if (legacy_id >= m_NextDowntimeID) if (legacy_id >= l_NextDowntimeID)
m_NextDowntimeID = legacy_id + 1; l_NextDowntimeID = legacy_id + 1;
if (newLegacyDowntimesCache.find(legacy_id) != newLegacyDowntimesCache.end()) { if (newLegacyDowntimesCache.find(legacy_id) != newLegacyDowntimesCache.end()) {
/* The legacy_id is already in use by another downtime; /* The legacy_id is already in use by another downtime;
* this shouldn't usually happen - assign it a new ID. */ * this shouldn't usually happen - assign it a new ID. */
legacy_id = m_NextDowntimeID++; legacy_id = l_NextDowntimeID++;
downtime->Set("legacy_id", legacy_id); downtime->Set("legacy_id", legacy_id);
service->Touch("downtimes"); service->Touch("downtimes");
} }
@ -320,16 +321,16 @@ void Service::RefreshDowntimesCache(void)
} }
} }
boost::mutex::scoped_lock lock(m_DowntimeMutex); boost::mutex::scoped_lock lock(l_DowntimeMutex);
m_DowntimesCache.swap(newDowntimesCache); l_DowntimesCache.swap(newDowntimesCache);
m_LegacyDowntimesCache.swap(newLegacyDowntimesCache); l_LegacyDowntimesCache.swap(newLegacyDowntimesCache);
if (!m_DowntimesExpireTimer) { if (!l_DowntimesExpireTimer) {
m_DowntimesExpireTimer = boost::make_shared<Timer>(); l_DowntimesExpireTimer = boost::make_shared<Timer>();
m_DowntimesExpireTimer->SetInterval(300); l_DowntimesExpireTimer->SetInterval(300);
m_DowntimesExpireTimer->OnTimerExpired.connect(boost::bind(&Service::DowntimesExpireTimerHandler)); l_DowntimesExpireTimer->OnTimerExpired.connect(boost::bind(&Service::DowntimesExpireTimerHandler));
m_DowntimesExpireTimer->Start(); l_DowntimesExpireTimer->Start();
} }
} }

View File

@ -31,10 +31,10 @@
using namespace icinga; using namespace icinga;
boost::mutex Service::m_NotificationMutex; static boost::mutex l_NotificationMutex;
std::map<String, std::set<Notification::WeakPtr> > Service::m_NotificationsCache; static std::map<String, std::set<Notification::WeakPtr> > l_NotificationsCache;
bool Service::m_NotificationsCacheNeedsUpdate = false; static bool l_NotificationsCacheNeedsUpdate = false;
Timer::Ptr Service::m_NotificationsCacheTimer; static Timer::Ptr l_NotificationsCacheTimer;
/** /**
* @threadsafety Always. * @threadsafety Always.
@ -96,19 +96,19 @@ void Service::SendNotifications(NotificationType type, const Dictionary::Ptr& cr
*/ */
void Service::InvalidateNotificationsCache(void) void Service::InvalidateNotificationsCache(void)
{ {
boost::mutex::scoped_lock lock(m_NotificationMutex); boost::mutex::scoped_lock lock(l_NotificationMutex);
if (m_NotificationsCacheNeedsUpdate) if (l_NotificationsCacheNeedsUpdate)
return; /* Someone else has already requested a refresh. */ return; /* Someone else has already requested a refresh. */
if (!m_NotificationsCacheTimer) { if (!l_NotificationsCacheTimer) {
m_NotificationsCacheTimer = boost::make_shared<Timer>(); l_NotificationsCacheTimer = boost::make_shared<Timer>();
m_NotificationsCacheTimer->SetInterval(0.5); l_NotificationsCacheTimer->SetInterval(0.5);
m_NotificationsCacheTimer->OnTimerExpired.connect(boost::bind(&Service::RefreshNotificationsCache)); l_NotificationsCacheTimer->OnTimerExpired.connect(boost::bind(&Service::RefreshNotificationsCache));
m_NotificationsCacheTimer->Start(); l_NotificationsCacheTimer->Start();
} }
m_NotificationsCacheNeedsUpdate = true; l_NotificationsCacheNeedsUpdate = true;
} }
/** /**
@ -117,12 +117,12 @@ void Service::InvalidateNotificationsCache(void)
void Service::RefreshNotificationsCache(void) void Service::RefreshNotificationsCache(void)
{ {
{ {
boost::mutex::scoped_lock lock(m_NotificationMutex); boost::mutex::scoped_lock lock(l_NotificationMutex);
if (!m_NotificationsCacheNeedsUpdate) if (!l_NotificationsCacheNeedsUpdate)
return; return;
m_NotificationsCacheNeedsUpdate = false; l_NotificationsCacheNeedsUpdate = false;
} }
Log(LogDebug, "icinga", "Updating Service notifications cache."); Log(LogDebug, "icinga", "Updating Service notifications cache.");
@ -140,8 +140,8 @@ void Service::RefreshNotificationsCache(void)
newNotificationsCache[service->GetName()].insert(notification); newNotificationsCache[service->GetName()].insert(notification);
} }
boost::mutex::scoped_lock lock(m_NotificationMutex); boost::mutex::scoped_lock lock(l_NotificationMutex);
m_NotificationsCache.swap(newNotificationsCache); l_NotificationsCache.swap(newNotificationsCache);
} }
/** /**
@ -152,9 +152,9 @@ std::set<Notification::Ptr> Service::GetNotifications(void) const
std::set<Notification::Ptr> notifications; std::set<Notification::Ptr> notifications;
{ {
boost::mutex::scoped_lock lock(m_NotificationMutex); boost::mutex::scoped_lock lock(l_NotificationMutex);
BOOST_FOREACH(const Notification::WeakPtr& wservice, m_NotificationsCache[GetName()]) { BOOST_FOREACH(const Notification::WeakPtr& wservice, l_NotificationsCache[GetName()]) {
Notification::Ptr notification = wservice.lock(); Notification::Ptr notification = wservice.lock();
if (!notification) if (!notification)

View File

@ -301,15 +301,6 @@ private:
/* Downtimes */ /* Downtimes */
Attribute<Dictionary::Ptr> m_Downtimes; Attribute<Dictionary::Ptr> m_Downtimes;
static int m_NextDowntimeID;
static boost::mutex m_DowntimeMutex;
static std::map<int, String> m_LegacyDowntimesCache;
static std::map<String, Service::WeakPtr> m_DowntimesCache;
static bool m_DowntimesCacheNeedsUpdate;
static Timer::Ptr m_DowntimesCacheTimer;
static Timer::Ptr m_DowntimesExpireTimer;
static void DowntimesExpireTimerHandler(void); static void DowntimesExpireTimerHandler(void);
void RemoveExpiredDowntimes(void); void RemoveExpiredDowntimes(void);
@ -319,15 +310,6 @@ private:
/* Comments */ /* Comments */
Attribute<Dictionary::Ptr> m_Comments; Attribute<Dictionary::Ptr> m_Comments;
static int m_NextCommentID;
static boost::mutex m_CommentMutex;
static std::map<int, String> m_LegacyCommentsCache;
static std::map<String, Service::WeakPtr> m_CommentsCache;
static bool m_CommentsCacheNeedsUpdate;
static Timer::Ptr m_CommentsCacheTimer;
static Timer::Ptr m_CommentsExpireTimer;
static void CommentsExpireTimerHandler(void); static void CommentsExpireTimerHandler(void);
void AddCommentsToCache(void); void AddCommentsToCache(void);
@ -340,11 +322,6 @@ private:
Attribute<double> m_LastNotification; Attribute<double> m_LastNotification;
Attribute<double> m_NotificationInterval; Attribute<double> m_NotificationInterval;
static boost::mutex m_NotificationMutex;
static std::map<String, std::set<Notification::WeakPtr> > m_NotificationsCache;
static bool m_NotificationsCacheNeedsUpdate;
static Timer::Ptr m_NotificationsCacheTimer;
static void RefreshNotificationsCache(void); static void RefreshNotificationsCache(void);
}; };

View File

@ -22,15 +22,16 @@
#include "base/dynamictype.h" #include "base/dynamictype.h"
#include "base/objectlock.h" #include "base/objectlock.h"
#include "base/logger_fwd.h" #include "base/logger_fwd.h"
#include "base/timer.h"
#include <boost/smart_ptr/make_shared.hpp> #include <boost/smart_ptr/make_shared.hpp>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
using namespace icinga; using namespace icinga;
boost::mutex ServiceGroup::m_Mutex; static boost::mutex l_Mutex;
std::map<String, std::vector<Service::WeakPtr> > ServiceGroup::m_MembersCache; static std::map<String, std::vector<Service::WeakPtr> > l_MembersCache;
bool ServiceGroup::m_MembersCacheNeedsUpdate = false; static bool l_MembersCacheNeedsUpdate = false;
Timer::Ptr ServiceGroup::m_MembersCacheTimer; static Timer::Ptr l_MembersCacheTimer;
REGISTER_TYPE(ServiceGroup); REGISTER_TYPE(ServiceGroup);
@ -105,9 +106,9 @@ std::set<Service::Ptr> ServiceGroup::GetMembers(void) const
std::set<Service::Ptr> services; std::set<Service::Ptr> services;
{ {
boost::mutex::scoped_lock lock(m_Mutex); boost::mutex::scoped_lock lock(l_Mutex);
BOOST_FOREACH(const Service::WeakPtr& wservice, m_MembersCache[GetName()]) { BOOST_FOREACH(const Service::WeakPtr& wservice, l_MembersCache[GetName()]) {
Service::Ptr service = wservice.lock(); Service::Ptr service = wservice.lock();
if (!service) if (!service)
@ -125,19 +126,19 @@ std::set<Service::Ptr> ServiceGroup::GetMembers(void) const
*/ */
void ServiceGroup::InvalidateMembersCache(void) void ServiceGroup::InvalidateMembersCache(void)
{ {
boost::mutex::scoped_lock lock(m_Mutex); boost::mutex::scoped_lock lock(l_Mutex);
if (m_MembersCacheNeedsUpdate) if (l_MembersCacheNeedsUpdate)
return; /* Someone else has already requested a refresh. */ return; /* Someone else has already requested a refresh. */
if (!m_MembersCacheTimer) { if (!l_MembersCacheTimer) {
m_MembersCacheTimer = boost::make_shared<Timer>(); l_MembersCacheTimer = boost::make_shared<Timer>();
m_MembersCacheTimer->SetInterval(0.5); l_MembersCacheTimer->SetInterval(0.5);
m_MembersCacheTimer->OnTimerExpired.connect(boost::bind(&ServiceGroup::RefreshMembersCache)); l_MembersCacheTimer->OnTimerExpired.connect(boost::bind(&ServiceGroup::RefreshMembersCache));
m_MembersCacheTimer->Start(); l_MembersCacheTimer->Start();
} }
m_MembersCacheNeedsUpdate = true; l_MembersCacheNeedsUpdate = true;
} }
/** /**
@ -146,12 +147,12 @@ void ServiceGroup::InvalidateMembersCache(void)
void ServiceGroup::RefreshMembersCache(void) void ServiceGroup::RefreshMembersCache(void)
{ {
{ {
boost::mutex::scoped_lock lock(m_Mutex); boost::mutex::scoped_lock lock(l_Mutex);
if (!m_MembersCacheNeedsUpdate) if (!l_MembersCacheNeedsUpdate)
return; return;
m_MembersCacheNeedsUpdate = false; l_MembersCacheNeedsUpdate = false;
} }
Log(LogDebug, "icinga", "Updating ServiceGroup members cache."); Log(LogDebug, "icinga", "Updating ServiceGroup members cache.");
@ -171,6 +172,6 @@ void ServiceGroup::RefreshMembersCache(void)
} }
} }
boost::mutex::scoped_lock lock(m_Mutex); boost::mutex::scoped_lock lock(l_Mutex);
m_MembersCache.swap(newMembersCache); l_MembersCache.swap(newMembersCache);
} }

View File

@ -60,11 +60,6 @@ private:
Attribute<String> m_NotesUrl; Attribute<String> m_NotesUrl;
Attribute<String> m_ActionUrl; Attribute<String> m_ActionUrl;
static boost::mutex m_Mutex;
static std::map<String, std::vector<Service::WeakPtr> > m_MembersCache;
static bool m_MembersCacheNeedsUpdate;
static Timer::Ptr m_MembersCacheTimer;
static void RefreshMembersCache(void); static void RefreshMembersCache(void);
}; };

View File

@ -18,11 +18,12 @@
******************************************************************************/ ******************************************************************************/
#include "icinga/timeperiod.h" #include "icinga/timeperiod.h"
#include "config/configitem.h"
#include "base/dynamictype.h" #include "base/dynamictype.h"
#include "base/scriptfunction.h" #include "base/scriptfunction.h"
#include "base/objectlock.h" #include "base/objectlock.h"
#include "base/logger_fwd.h" #include "base/logger_fwd.h"
#include "config/configitem.h" #include "base/timer.h"
#include <boost/smart_ptr/make_shared.hpp> #include <boost/smart_ptr/make_shared.hpp>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
@ -32,7 +33,7 @@ REGISTER_TYPE(TimePeriod);
REGISTER_SCRIPTFUNCTION(EmptyTimePeriod, &TimePeriod::EmptyTimePeriodUpdate); REGISTER_SCRIPTFUNCTION(EmptyTimePeriod, &TimePeriod::EmptyTimePeriodUpdate);
REGISTER_SCRIPTFUNCTION(EvenMinutesTimePeriod, &TimePeriod::EvenMinutesTimePeriodUpdate); REGISTER_SCRIPTFUNCTION(EvenMinutesTimePeriod, &TimePeriod::EvenMinutesTimePeriodUpdate);
Timer::Ptr TimePeriod::m_UpdateTimer; static Timer::Ptr l_UpdateTimer;
TimePeriod::TimePeriod(const Dictionary::Ptr& serializedUpdate) TimePeriod::TimePeriod(const Dictionary::Ptr& serializedUpdate)
: DynamicObject(serializedUpdate) : DynamicObject(serializedUpdate)
@ -41,11 +42,11 @@ TimePeriod::TimePeriod(const Dictionary::Ptr& serializedUpdate)
RegisterAttribute("valid_end", Attribute_Replicated, &m_ValidEnd); RegisterAttribute("valid_end", Attribute_Replicated, &m_ValidEnd);
RegisterAttribute("segments", Attribute_Replicated, &m_Segments); RegisterAttribute("segments", Attribute_Replicated, &m_Segments);
if (!m_UpdateTimer) { if (!l_UpdateTimer) {
m_UpdateTimer = boost::make_shared<Timer>(); l_UpdateTimer = boost::make_shared<Timer>();
m_UpdateTimer->SetInterval(300); l_UpdateTimer->SetInterval(300);
m_UpdateTimer->OnTimerExpired.connect(boost::bind(&TimePeriod::UpdateTimerHandler)); l_UpdateTimer->OnTimerExpired.connect(boost::bind(&TimePeriod::UpdateTimerHandler));
m_UpdateTimer->Start(); l_UpdateTimer->Start();
} }
} }
@ -324,11 +325,11 @@ void TimePeriod::EvenMinutesTimePeriodUpdate(const ScriptTask::Ptr& task, const
Array::Ptr segments = boost::make_shared<Array>(); Array::Ptr segments = boost::make_shared<Array>();
for (long t = begin; t < end; t += 60) { for (long t = begin / 60 - 1; t * 60 < end; t++) {
if ((t / 60) % 2 == 0) { if ((t % 2) == 0) {
Dictionary::Ptr segment = boost::make_shared<Dictionary>(); Dictionary::Ptr segment = boost::make_shared<Dictionary>();
segment->Set("begin", t); segment->Set("begin", t * 60);
segment->Set("end", t + 60); segment->Set("end", t * 61);
segments->Add(segment); segments->Add(segment);
} }

View File

@ -62,7 +62,6 @@ private:
void RemoveSegment(double begin, double end); void RemoveSegment(double begin, double end);
void PurgeSegments(double end); void PurgeSegments(double end);
static Timer::Ptr m_UpdateTimer;
static void UpdateTimerHandler(void); static void UpdateTimerHandler(void);
}; };

View File

@ -21,15 +21,16 @@
#include "base/dynamictype.h" #include "base/dynamictype.h"
#include "base/objectlock.h" #include "base/objectlock.h"
#include "base/logger_fwd.h" #include "base/logger_fwd.h"
#include "base/timer.h"
#include <boost/smart_ptr/make_shared.hpp> #include <boost/smart_ptr/make_shared.hpp>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
using namespace icinga; using namespace icinga;
boost::mutex UserGroup::m_Mutex; static boost::mutex l_Mutex;
std::map<String, std::vector<User::WeakPtr> > UserGroup::m_MembersCache; static std::map<String, std::vector<User::WeakPtr> > l_MembersCache;
bool UserGroup::m_MembersCacheNeedsUpdate = false; static bool l_MembersCacheNeedsUpdate = false;
Timer::Ptr UserGroup::m_MembersCacheTimer; static Timer::Ptr l_MembersCacheTimer;
REGISTER_TYPE(UserGroup); REGISTER_TYPE(UserGroup);
@ -86,9 +87,9 @@ std::set<User::Ptr> UserGroup::GetMembers(void) const
std::set<User::Ptr> users; std::set<User::Ptr> users;
{ {
boost::mutex::scoped_lock lock(m_Mutex); boost::mutex::scoped_lock lock(l_Mutex);
BOOST_FOREACH(const User::WeakPtr& wuser, m_MembersCache[GetName()]) { BOOST_FOREACH(const User::WeakPtr& wuser, l_MembersCache[GetName()]) {
User::Ptr user = wuser.lock(); User::Ptr user = wuser.lock();
if (!user) if (!user)
@ -106,19 +107,19 @@ std::set<User::Ptr> UserGroup::GetMembers(void) const
*/ */
void UserGroup::InvalidateMembersCache(void) void UserGroup::InvalidateMembersCache(void)
{ {
boost::mutex::scoped_lock lock(m_Mutex); boost::mutex::scoped_lock lock(l_Mutex);
if (m_MembersCacheNeedsUpdate) if (l_MembersCacheNeedsUpdate)
return; /* Someone else has already requested a refresh. */ return; /* Someone else has already requested a refresh. */
if (!m_MembersCacheTimer) { if (!l_MembersCacheTimer) {
m_MembersCacheTimer = boost::make_shared<Timer>(); l_MembersCacheTimer = boost::make_shared<Timer>();
m_MembersCacheTimer->SetInterval(0.5); l_MembersCacheTimer->SetInterval(0.5);
m_MembersCacheTimer->OnTimerExpired.connect(boost::bind(&UserGroup::RefreshMembersCache)); l_MembersCacheTimer->OnTimerExpired.connect(boost::bind(&UserGroup::RefreshMembersCache));
m_MembersCacheTimer->Start(); l_MembersCacheTimer->Start();
} }
m_MembersCacheNeedsUpdate = true; l_MembersCacheNeedsUpdate = true;
} }
/** /**
@ -127,12 +128,12 @@ void UserGroup::InvalidateMembersCache(void)
void UserGroup::RefreshMembersCache(void) void UserGroup::RefreshMembersCache(void)
{ {
{ {
boost::mutex::scoped_lock lock(m_Mutex); boost::mutex::scoped_lock lock(l_Mutex);
if (!m_MembersCacheNeedsUpdate) if (!l_MembersCacheNeedsUpdate)
return; return;
m_MembersCacheNeedsUpdate = false; l_MembersCacheNeedsUpdate = false;
} }
Log(LogDebug, "icinga", "Updating UserGroup members cache."); Log(LogDebug, "icinga", "Updating UserGroup members cache.");
@ -152,6 +153,6 @@ void UserGroup::RefreshMembersCache(void)
} }
} }
boost::mutex::scoped_lock lock(m_Mutex); boost::mutex::scoped_lock lock(l_Mutex);
m_MembersCache.swap(newMembersCache); l_MembersCache.swap(newMembersCache);
} }

View File

@ -55,11 +55,6 @@ protected:
private: private:
Attribute<String> m_DisplayName; Attribute<String> m_DisplayName;
static boost::mutex m_Mutex;
static std::map<String, std::vector<User::WeakPtr> > m_MembersCache;
static bool m_MembersCacheNeedsUpdate;
static Timer::Ptr m_MembersCacheTimer;
static void RefreshMembersCache(void); static void RefreshMembersCache(void);
}; };

View File

@ -5,7 +5,6 @@ pkglib_LTLIBRARIES = \
libpython.la libpython.la
libpython_la_SOURCES = \ libpython_la_SOURCES = \
i2-python.h \
pythoninterpreter.cpp \ pythoninterpreter.cpp \
pythoninterpreter.h \ pythoninterpreter.h \
pythonlanguage.cpp \ pythonlanguage.cpp \

View File

@ -1,22 +0,0 @@
/******************************************************************************
* Icinga 2 *
* Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software Foundation *
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
******************************************************************************/
/* This file is used by MSVC to generate the pre-compiled hedader. */
#include "i2-python.h"

View File

@ -1,39 +0,0 @@
/******************************************************************************
* Icinga 2 *
* Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software Foundation *
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
******************************************************************************/
#ifndef I2PYTHON_H
#define I2PYTHON_H
/**
* @defgroup python Icinga python support
*
* Lets you integrate Python scripts into Icinga.
*/
#include <Python.h>
#include <i2-base.h>
#ifdef I2_PYTHON_BUILD
# define I2_PYTHON_API I2_EXPORT
#else /* I2_PYTHON_BUILD */
# define I2_PYTHON_API I2_IMPORT
#endif /* I2_PYTHON_BUILD */
#endif /* I2PYTHON_H */

View File

@ -17,7 +17,10 @@
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
******************************************************************************/ ******************************************************************************/
#include "i2-python.h" #include "python/pythoninterpreter.h"
#include "base/objectlock.h"
#include "base/utility.h"
#include <boost/foreach.hpp>
using namespace icinga; using namespace icinga;
@ -72,7 +75,7 @@ void PythonInterpreter::UnregisterPythonFunction(const String& name)
} }
void PythonInterpreter::ProcessCall(const ScriptTask::Ptr& task, const String& function, void PythonInterpreter::ProcessCall(const ScriptTask::Ptr& task, const String& function,
const vector<Value>& arguments) const std::vector<Value>& arguments)
{ {
ObjectLock olock(this); ObjectLock olock(this);
@ -81,10 +84,10 @@ void PythonInterpreter::ProcessCall(const ScriptTask::Ptr& task, const String& f
m_Language->SetCurrentInterpreter(this); m_Language->SetCurrentInterpreter(this);
try { try {
map<String, PyObject *>::iterator it = m_Functions.find(function); std::map<String, PyObject *>::iterator it = m_Functions.find(function);
if (it == m_Functions.end()) if (it == m_Functions.end())
BOOST_THROW_EXCEPTION(invalid_argument("Function '" + function + "' does not exist.")); BOOST_THROW_EXCEPTION(std::invalid_argument("Function '" + function + "' does not exist."));
PyObject *func = it->second; PyObject *func = it->second;
@ -111,15 +114,15 @@ void PythonInterpreter::ProcessCall(const ScriptTask::Ptr& task, const String& f
Py_XDECREF(pvalue); Py_XDECREF(pvalue);
Py_XDECREF(ptraceback); Py_XDECREF(ptraceback);
BOOST_THROW_EXCEPTION(runtime_error("Error in Python script: " + msg)); BOOST_THROW_EXCEPTION(std::runtime_error("Error in Python script: " + msg));
} }
Value vresult = PythonLanguage::MarshalFromPython(result); Value vresult = PythonLanguage::MarshalFromPython(result);
Py_DECREF(result); Py_DECREF(result);
Application::GetEQ().Post(boost::bind(&ScriptTask::FinishResult, task, vresult)); Utility::QueueAsyncCallback(boost::bind(&ScriptTask::FinishResult, task, vresult));
} catch (...) { } catch (...) {
Application::GetEQ().Post(boost::bind(&ScriptTask::FinishException, task, boost::current_exception())); Utility::QueueAsyncCallback(boost::bind(&ScriptTask::FinishException, task, boost::current_exception()));
} }
m_Language->SetCurrentInterpreter(interp); m_Language->SetCurrentInterpreter(interp);

View File

@ -20,6 +20,10 @@
#ifndef PYTHONINTERPRETER_H #ifndef PYTHONINTERPRETER_H
#define PYTHONINTERPRETER_H #define PYTHONINTERPRETER_H
#include <Python.h>
#include "python/pythonlanguage.h"
#include "base/scriptinterpreter.h"
namespace icinga namespace icinga
{ {
@ -28,7 +32,7 @@ namespace icinga
* *
* @ingroup base * @ingroup base
*/ */
class I2_PYTHON_API PythonInterpreter : public ScriptInterpreter class PythonInterpreter : public ScriptInterpreter
{ {
public: public:
typedef shared_ptr<PythonInterpreter> Ptr; typedef shared_ptr<PythonInterpreter> Ptr;
@ -43,10 +47,10 @@ public:
protected: protected:
PythonLanguage::Ptr m_Language; PythonLanguage::Ptr m_Language;
PyThreadState *m_ThreadState; PyThreadState *m_ThreadState;
map<String, PyObject *> m_Functions; std::map<String, PyObject *> m_Functions;
virtual void ProcessCall(const ScriptTask::Ptr& task, const String& function, virtual void ProcessCall(const ScriptTask::Ptr& task, const String& function,
const vector<Value>& arguments); const std::vector<Value>& arguments);
}; };
} }

View File

@ -17,7 +17,15 @@
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
******************************************************************************/ ******************************************************************************/
#include "i2-python.h" #include "python/pythonlanguage.h"
#include "python/pythoninterpreter.h"
#include "base/dynamictype.h"
#include "base/objectlock.h"
#include "base/application.h"
#include "base/array.h"
#include <boost/foreach.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/exception/diagnostic_information.hpp>
using namespace icinga; using namespace icinga;
@ -60,7 +68,7 @@ void PythonLanguage::InitializeOnce(void)
PyEval_ReleaseLock(); PyEval_ReleaseLock();
String name; String name;
BOOST_FOREACH(tie(name, tuples::ignore), ScriptFunctionRegistry::GetInstance()->GetItems()) { BOOST_FOREACH(boost::tie(name, boost::tuples::ignore), ScriptFunctionRegistry::GetInstance()->GetItems()) {
RegisterNativeFunction(name); RegisterNativeFunction(name);
} }
@ -148,7 +156,7 @@ PyObject *PythonLanguage::MarshalToPython(const Value& value)
String key; String key;
Value value; Value value;
BOOST_FOREACH(tie(key, value), dict) { BOOST_FOREACH(boost::tie(key, value), dict) {
PyObject *dv = MarshalToPython(value); PyObject *dv = MarshalToPython(value);
PyDict_SetItemString(pdict, key.CStr(), dv); PyDict_SetItemString(pdict, key.CStr(), dv);
@ -178,7 +186,7 @@ PyObject *PythonLanguage::MarshalToPython(const Value& value)
return Py_None; return Py_None;
default: default:
BOOST_THROW_EXCEPTION(invalid_argument("Unexpected variant type.")); BOOST_THROW_EXCEPTION(std::invalid_argument("Unexpected variant type."));
} }
} }
@ -217,21 +225,21 @@ Value PythonLanguage::MarshalFromPython(PyObject *value)
ptype = PyTuple_GetItem(value, 0); ptype = PyTuple_GetItem(value, 0);
if (ptype == NULL || !PyString_Check(ptype)) if (ptype == NULL || !PyString_Check(ptype))
BOOST_THROW_EXCEPTION(invalid_argument("Tuple must contain two strings.")); BOOST_THROW_EXCEPTION(std::invalid_argument("Tuple must contain two strings."));
String type = PyString_AsString(ptype); String type = PyString_AsString(ptype);
pname = PyTuple_GetItem(value, 1); pname = PyTuple_GetItem(value, 1);
if (pname == NULL || !PyString_Check(pname)) if (pname == NULL || !PyString_Check(pname))
BOOST_THROW_EXCEPTION(invalid_argument("Tuple must contain two strings.")); BOOST_THROW_EXCEPTION(std::invalid_argument("Tuple must contain two strings."));
String name = PyString_AsString(pname); String name = PyString_AsString(pname);
DynamicObject::Ptr object = DynamicObject::GetObject(type, name); DynamicObject::Ptr object = DynamicObject::GetObject(type, name);
if (!object) if (!object)
BOOST_THROW_EXCEPTION(invalid_argument("Object '" + name + "' of type '" + type + "' does not exist.")); BOOST_THROW_EXCEPTION(std::invalid_argument("Object '" + name + "' of type '" + type + "' does not exist."));
return object; return object;
} else if (PyFloat_Check(value)) { } else if (PyFloat_Check(value)) {
@ -293,7 +301,7 @@ PyObject *PythonLanguage::PyCallNativeFunction(PyObject *self, PyObject *args)
ScriptFunction::Ptr function = ScriptFunctionRegistry::GetInstance()->GetItem(name); ScriptFunction::Ptr function = ScriptFunctionRegistry::GetInstance()->GetItem(name);
vector<Value> arguments; std::vector<Value> arguments;
if (args != NULL) { if (args != NULL) {
if (PyTuple_Check(args)) { if (PyTuple_Check(args)) {
@ -318,7 +326,7 @@ PyObject *PythonLanguage::PyCallNativeFunction(PyObject *self, PyObject *args)
} catch (const std::exception& ex) { } catch (const std::exception& ex) {
PyEval_RestoreThread(tstate); PyEval_RestoreThread(tstate);
String message = diagnostic_information(ex); String message = boost::diagnostic_information(ex);
PyErr_SetString(PyExc_RuntimeError, message.CStr()); PyErr_SetString(PyExc_RuntimeError, message.CStr());
return NULL; return NULL;

View File

@ -20,6 +20,9 @@
#ifndef PYTHONLANGUAGE_H #ifndef PYTHONLANGUAGE_H
#define PYTHONLANGUAGE_H #define PYTHONLANGUAGE_H
#include <Python.h>
#include "base/scriptlanguage.h"
namespace icinga namespace icinga
{ {
@ -30,7 +33,7 @@ class PythonInterpreter;
* *
* @ingroup base * @ingroup base
*/ */
class I2_PYTHON_API PythonLanguage : public ScriptLanguage class PythonLanguage : public ScriptLanguage
{ {
public: public:
typedef shared_ptr<PythonLanguage> Ptr; typedef shared_ptr<PythonLanguage> Ptr;

View File

@ -22,6 +22,7 @@
#include "base/application.h" #include "base/application.h"
#include "base/dynamictype.h" #include "base/dynamictype.h"
#include "base/objectlock.h" #include "base/objectlock.h"
#include "base/utility.h"
#include "base/logger_fwd.h" #include "base/logger_fwd.h"
#include "config/configitembuilder.h" #include "config/configitembuilder.h"
#include <boost/smart_ptr/make_shared.hpp> #include <boost/smart_ptr/make_shared.hpp>

View File

@ -22,6 +22,7 @@
#include "base/objectlock.h" #include "base/objectlock.h"
#include "base/logger_fwd.h" #include "base/logger_fwd.h"
#include "base/convert.h" #include "base/convert.h"
#include "base/utility.h"
#include <boost/tuple/tuple.hpp> #include <boost/tuple/tuple.hpp>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>

View File

@ -24,6 +24,8 @@
#include "remoting/endpoint.h" #include "remoting/endpoint.h"
#include "base/tcpsocket.h" #include "base/tcpsocket.h"
#include "base/tlsstream.h" #include "base/tlsstream.h"
#include "base/timer.h"
#include "base/utility.h"
#include <boost/signals2.hpp> #include <boost/signals2.hpp>
namespace icinga namespace icinga