]> granicus.if.org Git - icinga2/commitdiff
Prefer boost::* over C++0x features.
authorGunnar Beutner <gunnar@beutner.name>
Fri, 15 Jun 2012 17:32:41 +0000 (19:32 +0200)
committerGunnar Beutner <gunnar@beutner.name>
Fri, 15 Jun 2012 17:32:41 +0000 (19:32 +0200)
56 files changed:
base/Makefile.am
base/application.cpp
base/application.h
base/base.vcxproj
base/configobject.cpp
base/cxx11-compat.h [deleted file]
base/exception.cpp
base/fifo.cpp
base/i2-base.h
base/objectmap.h
base/objectset.h
base/socket.cpp
base/socket.h
base/tcpclient.cpp
base/tcpclient.h
base/tcpserver.cpp
base/tcpsocket.cpp
base/timer.cpp
base/timer.h
base/tlsclient.cpp
base/tlsclient.h
components/checker/checkercomponent.cpp
components/checker/checkercomponent.h
components/checker/i2-checker.h
components/configfile/configfilecomponent.cpp
components/configrpc/configrpccomponent.cpp
components/configrpc/configrpccomponent.h
components/delegation/delegationcomponent.cpp
components/delegation/delegationcomponent.h
components/demo/democomponent.cpp
components/demo/democomponent.h
components/discovery/discoverycomponent.cpp
components/discovery/discoverycomponent.h
config/ax_cxx_compile_stdcxx_0x.m4 [deleted file]
configure.ac
dyn/config_parser.cc
dyn/config_parser.yy
dyn/configcompiler.cpp
dyn/configitem.cpp
dyn/expression.cpp
dyn/i2-dyn.h
dyntest/dyntest.cpp
icinga-app/icinga.cpp
icinga/endpointmanager.cpp
icinga/endpointmanager.h
icinga/icingaapplication.cpp
icinga/icingaapplication.h
icinga/jsonrpcendpoint.cpp
icinga/jsonrpcendpoint.h
icinga/nagioschecktask.cpp
icinga/virtualendpoint.cpp
icinga/virtualendpoint.h
jsonrpc/jsonrpcclient.cpp
jsonrpc/jsonrpcclient.h
jsonrpc/jsonrpcserver.cpp
jsonrpc/messagepart.cpp

index f95a3975836f85e7b8f7e7a2eb1a195c88f8c669..f1aab07a1c450385e04549e75d0a5db50ec5e153 100644 (file)
@@ -11,11 +11,8 @@ libbase_la_SOURCES =  \
        component.h \
        configobject.cpp \
        configobject.h \
-       cxx11-compat.h \
-       delegate.h \
        dictionary.cpp \
        dictionary.h \
-       observable.h \
        exception.cpp \
        exception.h \
        fifo.cpp \
index a277104d8808ec0f4f4786d347093238dc28748b..4f7f95c38f117bd15ad993b8a10fc81241012793 100644 (file)
@@ -23,6 +23,9 @@
 #      include <ltdl.h>
 #endif
 
+using std::cout;
+using std::endl;
+
 using namespace icinga;
 
 Application::Ptr I2_EXPORT Application::m_Instance;
@@ -210,7 +213,7 @@ Component::Ptr Application::LoadComponent(const string& path,
        Component::Ptr component;
        Component *(*pCreateComponent)();
 
-       Log("Loading component '" + path + "'");
+       Log(LogInformation, "base", "Loading component '" + path + "'");
 
 #ifdef _WIN32
        HMODULE hModule = LoadLibrary(path.c_str());
@@ -264,7 +267,7 @@ void Application::UnregisterComponent(Component::Ptr component)
 {
        string name = component->GetName();
 
-       Log("Unloading component '" + name + "'");
+       Log(LogInformation, "base", "Unloading component '" + name + "'");
        map<string, Component::Ptr>::iterator i = m_Components.find(name);
        if (i != m_Components.end())
                m_Components.erase(i);
@@ -291,19 +294,41 @@ Component::Ptr Application::GetComponent(const string& name) const
 /**
  * Writes a message to the application's log.
  *
+ * @param severity The message severity.
+ * @param facility The log facility.
  * @param message The message.
  */
-void Application::Log(string message)
+void Application::Log(LogSeverity severity, string facility, string message)
 {
        char timestamp[100];
 
+       string severityStr;
+       switch (severity) {
+               case LogDebug:
+                       severityStr = "debug";
+                       break;
+               case LogInformation:
+                       severityStr = "info";
+                       break;
+               case LogWarning:
+                       severityStr = "warning";
+                       break;
+               case LogCritical:
+                       severityStr = "critical";
+                       break;
+               default:
+                       assert(!"Invalid severity specified.");
+       }
+
        time_t now;
        time(&now);
        tm tmnow = *localtime(&now);
 
-       strftime(timestamp, sizeof(timestamp), "%a %B %d %Y %H:%M:%S", &tmnow);
+       strftime(timestamp, sizeof(timestamp), "%Y/%m/%d %H:%M:%S", &tmnow);
 
-       cout << "[" << timestamp << "]: " << message << endl;
+       cout << "[" << timestamp << "] "
+                << severityStr << "/" << facility << ": "
+                << message << endl;
 }
 
 /**
@@ -483,9 +508,9 @@ int Application::Run(int argc, char **argv)
                } catch (const std::exception& ex) {
                        Application::m_Instance.reset();
 
-                       Application::Log("---");
-                       Application::Log("Exception: " + Utility::GetTypeName(ex));
-                       Application::Log("Message: " + string(ex.what()));
+                       Application::Log(LogCritical, "base", "---");
+                       Application::Log(LogCritical, "base", "Exception: " + Utility::GetTypeName(ex));
+                       Application::Log(LogCritical, "base", "Message: " + string(ex.what()));
 
                        return EXIT_FAILURE;
                }
index 958608d2488f1407891edffcb2146cc93e2361c7..56383b049c97b303b6d50f8d415b63cc09b38359 100644 (file)
 
 namespace icinga {
 
+enum LogSeverity
+{
+       LogDebug,
+       LogInformation,
+       LogWarning,
+       LogCritical
+};
+
 class Component;
 
 /**
@@ -45,7 +53,7 @@ public:
 
        static void Shutdown(void);
 
-       static void Log(string message);
+       static void Log(LogSeverity severity, string facility, string message);
 
        shared_ptr<Component> LoadComponent(const string& path,
            const ConfigObject::Ptr& componentConfig);
index f7e4cc647543b4c07495330777641f5212754cf5..fd5a13cf42737f05702b3f31a7cc7bb918a4b119 100644 (file)
     <ClInclude Include="application.h" />
     <ClInclude Include="component.h" />
     <ClInclude Include="configobject.h" />
-    <ClInclude Include="cxx11-compat.h" />
-    <ClInclude Include="delegate.h" />
     <ClInclude Include="dictionary.h" />
+    <ClInclude Include="eventargs.h" />
     <ClInclude Include="objectmap.h" />
     <ClInclude Include="objectset.h" />
-    <ClInclude Include="observable.h" />
     <ClInclude Include="exception.h" />
     <ClInclude Include="fifo.h" />
     <ClInclude Include="i2-base.h" />
index fd5efcf7db5fad685e1934d1f0a3a48558b3023f..da273b4477c46a79d5d05d4e3fa9e2de38354d54 100644 (file)
@@ -23,12 +23,12 @@ using namespace icinga;
 
 ConfigObject::ConfigObject(Dictionary::Ptr properties, const ConfigObject::Set::Ptr& container)
        : m_Container(container ? container : GetAllObjects()),
-       m_Properties(properties), m_Tags(make_shared<Dictionary>())
+       m_Properties(properties), m_Tags(boost::make_shared<Dictionary>())
 { }
 
 ConfigObject::ConfigObject(string type, string name, const ConfigObject::Set::Ptr& container)
        : m_Container(container ? container : GetAllObjects()),
-       m_Properties(make_shared<Dictionary>()), m_Tags(make_shared<Dictionary>())
+       m_Properties(boost::make_shared<Dictionary>()), m_Tags(boost::make_shared<Dictionary>())
 {
        SetProperty("__type", type);
        SetProperty("__name", name);
@@ -106,7 +106,7 @@ ObjectSet<ConfigObject::Ptr>::Ptr ConfigObject::GetAllObjects(void)
        static ObjectSet<ConfigObject::Ptr>::Ptr allObjects;
 
        if (!allObjects) {
-               allObjects = make_shared<ObjectSet<ConfigObject::Ptr> >();
+               allObjects = boost::make_shared<ObjectSet<ConfigObject::Ptr> >();
                allObjects->Start();
        }
 
@@ -118,7 +118,7 @@ ConfigObject::TNMap::Ptr ConfigObject::GetObjectsByTypeAndName(void)
        static ConfigObject::TNMap::Ptr tnmap;
 
        if (!tnmap) {
-               tnmap = make_shared<ConfigObject::TNMap>(GetAllObjects(), &ConfigObject::TypeAndNameGetter);
+               tnmap = boost::make_shared<ConfigObject::TNMap>(GetAllObjects(), &ConfigObject::TypeAndNameGetter);
                tnmap->Start();
        }
 
@@ -147,7 +147,7 @@ bool ConfigObject::TypeAndNameGetter(const ConfigObject::Ptr& object, pair<strin
 
 function<bool (ConfigObject::Ptr)> ConfigObject::MakeTypePredicate(string type)
 {
-       return bind(&ConfigObject::TypePredicate, _1, type);
+       return boost::bind(&ConfigObject::TypePredicate, _1, type);
 }
 
 bool ConfigObject::TypePredicate(const ConfigObject::Ptr& object, string type)
@@ -160,7 +160,7 @@ ConfigObject::TMap::Ptr ConfigObject::GetObjectsByType(void)
        static ObjectMap<string, ConfigObject::Ptr>::Ptr tmap;
 
        if (!tmap) {
-               tmap = make_shared<ConfigObject::TMap>(GetAllObjects(), &ConfigObject::TypeGetter);
+               tmap = boost::make_shared<ConfigObject::TMap>(GetAllObjects(), &ConfigObject::TypeGetter);
                tmap->Start();
        }
 
diff --git a/base/cxx11-compat.h b/base/cxx11-compat.h
deleted file mode 100644 (file)
index 684f6b5..0000000
+++ /dev/null
@@ -1,45 +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 CXX11COMPAT_H
-#define CXX11COMPAT_H
-
-namespace icinga {
-
-template <typename T>
-shared_ptr<T> make_shared(void)
-{
-       return shared_ptr<T>(new T());
-}
-
-template <typename T, typename TArg1>
-shared_ptr<T> make_shared(const TArg1& arg1)
-{
-       return shared_ptr<T>(new T(arg1));
-}
-
-template <typename T, typename TArg1, typename TArg2>
-shared_ptr<T> make_shared(const TArg1& arg1, const TArg2& arg2)
-{
-       return shared_ptr<T>(new T(arg1, arg2));
-}
-
-}
-
-#endif /* CXX11COMPAT_H */
index f0b609634501081ee6e3b09d434a6c0c88c43b4a..fbb796369be70bf98b37f4dc112b793d0cec9969 100644 (file)
@@ -90,6 +90,9 @@ string Win32Exception::FormatErrorCode(int code)
        if (rc != 0) {
                result = string(message);
                LocalFree(message);
+
+               /* remove trailing new-line characters */
+               boost::algorithm::trim_right(result);
        }
 
        return result;
index bb83e7c87c6d290c16ac4b2ffd60a0826d0f9d17..1a5caa65ac971602ce911d0afb4760a2fc14eb4c 100644 (file)
@@ -19,6 +19,8 @@
 
 #include "i2-base.h"
 
+using std::bad_alloc;
+
 using namespace icinga;
 
 /**
index 4dcc25e3ef9027c74bf2b189404c6dc012655f8f..c5182727dd939821d4c62e060900f3ea5ca9ee1c 100644 (file)
@@ -53,7 +53,6 @@
  */
 
 #ifdef _MSC_VER
-#      define HAVE_STDCXX_0X
 #      pragma warning(disable:4251)
 #      pragma warning(disable:4275)
 #      define _CRT_SECURE_NO_DEPRECATE
 #include <list>
 #include <algorithm>
 
-using namespace std;
-
-#ifdef HAVE_STDCXX_0X
-#      include <memory>
-#      include <functional>
-
-using namespace std::placeholders;
-
-#else /* HAVE_STDCXX_0X */
-#      ifdef HAVE_BOOST
-#              include <boost/smart_ptr.hpp>
-#              include <boost/make_shared.hpp>
-#              include <boost/bind.hpp>
-#              include <boost/function.hpp>
-
-using namespace boost;
-
-#      else /* HAVE_BOOST */
-#              include <tr1/memory>
-#              include <tr1/functional>
-#              include "cxx11-compat.h"
-
-using namespace std::tr1;
-using namespace std::tr1::placeholders;
-
-#endif /* HAVE_BOOST */
-#endif /* HAVE_STDCXX_0X */
-
+using std::string;
+using std::vector;
+using std::map;
+using std::list;
+using std::set;
+using std::multimap;
+using std::pair;
+
+using std::stringstream;
+
+using std::runtime_error;
+using std::logic_error;
+using std::invalid_argument;
+using std::domain_error;
+
+#include <boost/smart_ptr.hpp>
+#include <boost/make_shared.hpp>
+#include <boost/bind.hpp>
+#include <boost/function.hpp>
 #include <boost/signal.hpp>
+#include <boost/algorithm/string/trim.hpp>
+
+using boost::shared_ptr;
+using boost::weak_ptr;
+using boost::enable_shared_from_this;
+using boost::dynamic_pointer_cast;
+using boost::static_pointer_cast;
+using boost::function;
+using boost::signal;
 
 #if defined(__APPLE__) && defined(__MACH__)
 #      pragma GCC diagnostic ignored "-Wdeprecated-declarations" 
index 9b975412f79684b5dbba9f6488b98cabc176bb66..0fb42f55dcaab2e4ef926199d289510adb2fe7c6 100644 (file)
@@ -43,9 +43,9 @@ public:
 
        void Start(void)
        {
-               m_Parent->OnObjectAdded.connect(bind(&ObjectMap::ObjectAddedHandler, this, _1));
-               m_Parent->OnObjectCommitted.connect(bind(&ObjectMap::ObjectCommittedHandler, this, _1));
-               m_Parent->OnObjectRemoved.connect(bind(&ObjectMap::ObjectRemovedHandler, this, _1));
+               m_Parent->OnObjectAdded.connect(boost::bind(&ObjectMap::ObjectAddedHandler, this, _1));
+               m_Parent->OnObjectCommitted.connect(boost::bind(&ObjectMap::ObjectCommittedHandler, this, _1));
+               m_Parent->OnObjectRemoved.connect(boost::bind(&ObjectMap::ObjectRemovedHandler, this, _1));
 
                for (typename ObjectSet<TValue>::Iterator it = m_Parent->Begin(); it != m_Parent->End(); it++)
                        AddObject(*it);
@@ -56,7 +56,7 @@ public:
                return m_Objects.equal_range(key);
        }
 
-       void ForeachObject(TKey key, function<int (const ObjectSetEventArgs<TValue>&)> callback)
+       void ForeachObject(TKey key, function<void (const ObjectSetEventArgs<TValue>&)> callback)
        {
                ObjectSetEventArgs<TValue> ea;
                ea.Source = shared_from_this();
@@ -105,25 +105,19 @@ private:
                AddObject(object);
        }
 
-       int ObjectAddedHandler(const ObjectSetEventArgs<TValue>& ea)
+       void ObjectAddedHandler(const ObjectSetEventArgs<TValue>& ea)
        {
                AddObject(ea.Target);
-
-               return 0;
        }
 
-       int ObjectCommittedHandler(const ObjectSetEventArgs<TValue>& ea)
+       void ObjectCommittedHandler(const ObjectSetEventArgs<TValue>& ea)
        {
                CheckObject(ea.Target);
-
-               return 0;
        }
 
-       int ObjectRemovedHandler(const ObjectSetEventArgs<TValue>& ea)
+       void ObjectRemovedHandler(const ObjectSetEventArgs<TValue>& ea)
        {
                RemoveObject(ea.Target);
-
-               return 0;
        }
 };
 
index ad4d41c989c626317c6f75794402d3189b126d75..692723e8c690c6582238fa75f9b4ffe2abad80a7 100644 (file)
@@ -49,9 +49,9 @@ public:
        void Start(void)
        {
                if (m_Parent) {
-                       m_Parent->OnObjectAdded.connect(bind(&ObjectSet::ObjectAddedOrCommittedHandler, this, _1));
-                       m_Parent->OnObjectCommitted.connect(bind(&ObjectSet::ObjectAddedOrCommittedHandler, this, _1));
-                       m_Parent->OnObjectRemoved.connect(bind(&ObjectSet::ObjectRemovedHandler, this, _1));
+                       m_Parent->OnObjectAdded.connect(boost::bind(&ObjectSet::ObjectAddedOrCommittedHandler, this, _1));
+                       m_Parent->OnObjectCommitted.connect(boost::bind(&ObjectSet::ObjectAddedOrCommittedHandler, this, _1));
+                       m_Parent->OnObjectRemoved.connect(boost::bind(&ObjectSet::ObjectRemovedHandler, this, _1));
 
                        for (ObjectSet::Iterator it = m_Parent->Begin(); it != m_Parent->End(); it++)
                                CheckObject(*it);
@@ -86,9 +86,7 @@ public:
 
        bool Contains(const TValue& object) const
        {
-               ObjectSet::Iterator it = m_Objects.find(object);
-
-               return !(it == m_Objects.end());
+               return !(m_Objects.find(object) == m_Objects.end());
        }
 
        void CheckObject(const TValue& object)
@@ -121,7 +119,7 @@ public:
                return m_Objects.end();
        }
 
-       void ForeachObject(function<int (const ObjectSetEventArgs<TValue>&)> callback)
+       void ForeachObject(function<void (const ObjectSetEventArgs<TValue>&)> callback)
        {
                ObjectSetEventArgs<TValue> ea;
                ea.Source = shared_from_this();
@@ -138,18 +136,14 @@ private:
        typename ObjectSet<TValue>::Ptr m_Parent;
        function<bool (const TValue&)> m_Predicate;
 
-       int ObjectAddedOrCommittedHandler(const ObjectSetEventArgs<TValue>& ea)
+       void ObjectAddedOrCommittedHandler(const ObjectSetEventArgs<TValue>& ea)
        {
                CheckObject(ea.Target);
-
-               return 0;
        }
 
-       int ObjectRemovedHandler(const ObjectSetEventArgs<TValue>& ea)
+       void ObjectRemovedHandler(const ObjectSetEventArgs<TValue>& ea)
        {
                RemoveObject(ea.Target);
-
-               return 0;
        }
 };
 
index 6cee85988ede4bf3c1e271198dc829f93c2023b7..570c0363e4f9b6aa2eb9811ca196c9b35e9e8f19 100644 (file)
@@ -50,7 +50,7 @@ void Socket::Start(void)
 {
        assert(m_FD != INVALID_SOCKET);
 
-       OnException.connect(bind(&Socket::ExceptionEventHandler, this, _1));
+       OnException.connect(boost::bind(&Socket::ExceptionEventHandler, this, _1));
 
        Sockets.push_back(static_pointer_cast<Socket>(shared_from_this()));
 }
@@ -171,29 +171,25 @@ int Socket::GetLastSocketError(void)
  */
 void Socket::HandleSocketError(const std::exception& ex)
 {
-       // XXX, TODO: add SetErrorHandling() function
-/*     if (OnError.HasObservers()) {*/
+       if (!OnError.empty()) {
                SocketErrorEventArgs sea(ex);
                OnError(sea);
 
                Close();
-/*     } else {
+       } else {
                throw ex;
-       }*/
+       }
 }
 
 /**
  * Processes errors that have occured for the socket.
  *
  * @param - Event arguments for the socket error.
- * @returns 0
  */
-int Socket::ExceptionEventHandler(const EventArgs&)
+void Socket::ExceptionEventHandler(const EventArgs&)
 {
        HandleSocketError(SocketException(
            "select() returned fd in except fdset", GetError()));
-
-       return 0;
 }
 
 /**
index 9d111d4a4bea40fc9b946dd1370d8b803a594af2..feb8a2c58064fa73a6fbab204d0866bb758da55a 100644 (file)
@@ -85,7 +85,7 @@ protected:
 private:
        SOCKET m_FD; /**< The socket descriptor. */
 
-       int ExceptionEventHandler(const EventArgs& ea);
+       void ExceptionEventHandler(const EventArgs& ea);
 
        static string GetAddressFromSockaddr(sockaddr *address, socklen_t len);
 };
index 655253771ee69b7d8dbbc0a1aea18d00a9e6ee58..4b5e07113ad004bca65955d2aee695bc5d157399 100644 (file)
@@ -30,8 +30,8 @@ TcpClient::TcpClient(TcpClientRole role)
 {
        m_Role = role;
 
-       m_SendQueue = make_shared<FIFO>();
-       m_RecvQueue = make_shared<FIFO>();
+       m_SendQueue = boost::make_shared<FIFO>();
+       m_RecvQueue = boost::make_shared<FIFO>();
 }
 
 /**
@@ -51,8 +51,8 @@ void TcpClient::Start(void)
 {
        TcpSocket::Start();
 
-       OnReadable.connect(bind(&TcpClient::ReadableEventHandler, this, _1));
-       OnWritable.connect(bind(&TcpClient::WritableEventHandler, this, _1));
+       OnReadable.connect(boost::bind(&TcpClient::ReadableEventHandler, this, _1));
+       OnWritable.connect(boost::bind(&TcpClient::WritableEventHandler, this, _1));
 }
 
 /**
@@ -138,9 +138,8 @@ FIFO::Ptr TcpClient::GetRecvQueue(void)
  * Processes data that is available for this socket.
  *
  * @param - Event arguments.
- * @returns 0
  */
-int TcpClient::ReadableEventHandler(const EventArgs&)
+void TcpClient::ReadableEventHandler(const EventArgs&)
 {
        int rc;
 
@@ -153,11 +152,11 @@ int TcpClient::ReadableEventHandler(const EventArgs&)
 #else /* _WIN32 */
        if (rc < 0 && errno == EAGAIN)
 #endif /* _WIN32 */
-               return 0;
+               return;
 
        if (rc <= 0) {
                HandleSocketError(SocketException("recv() failed", GetError()));
-               return 0;
+               return;
        }
 
        m_RecvQueue->Write(NULL, rc);
@@ -165,17 +164,14 @@ int TcpClient::ReadableEventHandler(const EventArgs&)
        EventArgs dea;
        dea.Source = shared_from_this();
        OnDataAvailable(dea);
-
-       return 0;
 }
 
 /**
  * Processes data that can be written for this socket.
  *
  * @param - Event arguments.
- * @returns 0
  */
-int TcpClient::WritableEventHandler(const EventArgs&)
+void TcpClient::WritableEventHandler(const EventArgs&)
 {
        int rc;
 
@@ -183,12 +179,10 @@ int TcpClient::WritableEventHandler(const EventArgs&)
 
        if (rc <= 0) {
                HandleSocketError(SocketException("send() failed", GetError()));
-               return 0;
+               return;
        }
 
        m_SendQueue->Read(NULL, rc);
-
-       return 0;
 }
 
 /**
@@ -219,5 +213,5 @@ bool TcpClient::WantsToWrite(void) const
  */
 TcpClient::Ptr icinga::TcpClientFactory(TcpClientRole role)
 {
-       return make_shared<TcpClient>(role);
+       return boost::make_shared<TcpClient>(role);
 }
index 997c0ce052ac2e3e853d222925431709168c2c67..5f2d553cbd01ba727a78f128961fbbde7080ee14 100644 (file)
@@ -69,8 +69,8 @@ private:
        FIFO::Ptr m_SendQueue;
        FIFO::Ptr m_RecvQueue;
 
-       virtual int ReadableEventHandler(const EventArgs& ea);
-       virtual int WritableEventHandler(const EventArgs& ea);
+       virtual void ReadableEventHandler(const EventArgs& ea);
+       virtual void WritableEventHandler(const EventArgs& ea);
 };
 
 /**
index f790775dc7e3fddcb30254d8f7e5c631108e862a..e50343ff45a265c3ed3eb64ba6ec81d6d3d49517 100644 (file)
@@ -26,7 +26,7 @@ using namespace icinga;
  */
 TcpServer::TcpServer(void)
 {
-       m_ClientFactory = bind(&TcpClientFactory, RoleInbound);
+       m_ClientFactory = boost::bind(&TcpClientFactory, RoleInbound);
 }
 
 /**
@@ -56,7 +56,7 @@ void TcpServer::Start(void)
 {
        TcpSocket::Start();
 
-       OnReadable.connect(bind(&TcpServer::ReadableEventHandler, this, _1));
+       OnReadable.connect(boost::bind(&TcpServer::ReadableEventHandler, this, _1));
 }
 
 /**
index d2932e9a6eac9443864a1dcae39cca6d9dd37803..201328e7eaf941072e1388d9188e71e855d5a6b1 100644 (file)
@@ -97,7 +97,7 @@ void TcpSocket::Bind(string node, string service, int family)
                setsockopt(GetFD(), SOL_SOCKET, SO_REUSEADDR, (char *)&optTrue, sizeof(optTrue));
 #endif /* _WIN32 */
 
-               int rc = ::bind(fd, info->ai_addr, info->ai_addrlen);
+               int rc = bind(fd, info->ai_addr, info->ai_addrlen);
 
 #ifdef _WIN32
                if (rc < 0 && WSAGetLastError() != WSAEWOULDBLOCK) {
index 592c068b6c1dc503bf9c8f4620cec11fcb3fd311..bf212786e79b4b20606758291e0c6f2bedea326b 100644 (file)
@@ -100,9 +100,8 @@ void Timer::CallExpiredTimers(void)
  */
 void Timer::Call(void)
 {
-       TimerEventArgs tea;
+       EventArgs tea;
        tea.Source = shared_from_this();
-       tea.UserArgs = m_UserArgs;
        OnTimerExpired(tea);
 }
 
@@ -111,7 +110,7 @@ void Timer::Call(void)
  *
  * @param interval The new interval.
  */
-void Timer::SetInterval(unsigned int interval)
+void Timer::SetInterval(time_t interval)
 {
        m_Interval = interval;
 }
@@ -121,31 +120,11 @@ void Timer::SetInterval(unsigned int interval)
  *
  * @returns The interval.
  */
-unsigned int Timer::GetInterval(void) const
+time_t Timer::GetInterval(void) const
 {
        return m_Interval;
 }
 
-/**
- * Sets user arguments for the timer callback.
- *
- * @param userArgs The user arguments.
- */
-void Timer::SetUserArgs(const EventArgs& userArgs)
-{
-       m_UserArgs = userArgs;
-}
-
-/**
- * Retrieves the user arguments for the timer callback.
- *
- * @returns The user arguments.
- */
-EventArgs Timer::GetUserArgs(void) const
-{
-       return m_UserArgs;
-}
-
 /**
  * Registers the timer and starts processing events for it.
  */
index 9bf8bfa4e8d77adc920536f7541cc6386aa7cf8a..5f119e11a4f7471ddca4c3e35067d9e90bf72153 100644 (file)
 
 namespace icinga {
 
-/**
- * Event arguments for the "timer expired" event.
- *
- * @ingroup base
- */
-struct I2_BASE_API TimerEventArgs : public EventArgs
-{
-       EventArgs UserArgs; /**< User-specified event arguments. */
-};
-
 /**
  * A timer that periodically triggers an event.
  *
@@ -51,11 +41,8 @@ public:
 
        Timer(void);
 
-       void SetInterval(unsigned int interval);
-       unsigned int GetInterval(void) const;
-
-       void SetUserArgs(const EventArgs& userArgs);
-       EventArgs GetUserArgs(void) const;
+       void SetInterval(time_t interval);
+       time_t GetInterval(void) const;
 
        static time_t GetNextCall(void);
        static void CallExpiredTimers(void);
@@ -65,11 +52,10 @@ public:
 
        void Reschedule(time_t next);
 
-       boost::signal<void (const TimerEventArgs&)> OnTimerExpired;
+       boost::signal<void(const EventArgs&)> OnTimerExpired;
 
 private:
-       EventArgs m_UserArgs; /**< User-specified event arguments. */
-       unsigned int m_Interval; /**< The interval of the timer. */
+       time_t m_Interval; /**< The interval of the timer. */
        time_t m_Next; /**< When the next event should happen. */
 
        static time_t NextCall; /**< When the next event should happen (for all timers). */
index 2669b4d26e9a631dba5f4f60c53d720c89745420..886b5ea6cd771b49729ab8c78381cd3923654e4a 100644 (file)
@@ -107,9 +107,8 @@ void TlsClient::Start(void)
  * Processes data that is available for this socket.
  *
  * @param - Event arguments.
- * @returns 0
  */
-int TlsClient::ReadableEventHandler(const EventArgs&)
+void TlsClient::ReadableEventHandler(const EventArgs&)
 {
        int rc;
 
@@ -126,16 +125,14 @@ int TlsClient::ReadableEventHandler(const EventArgs&)
                                m_BlockRead = true;
                                /* fall through */
                        case SSL_ERROR_WANT_READ:
-                               return 0;
+                               return;
                        case SSL_ERROR_ZERO_RETURN:
                                Close();
-
-                               return 0;
+                               return;
                        default:
                                HandleSocketError(OpenSSLException(
                                    "SSL_read failed", ERR_get_error()));
-
-                               return 0;
+                               return;
                }
        }
 
@@ -144,17 +141,14 @@ int TlsClient::ReadableEventHandler(const EventArgs&)
        EventArgs dea;
        dea.Source = shared_from_this();
        OnDataAvailable(dea);
-
-       return 0;
 }
 
 /**
  * Processes data that can be written for this socket.
  *
  * @param - Event arguments.
- * @returns 0
  */
-int TlsClient::WritableEventHandler(const EventArgs&)
+void TlsClient::WritableEventHandler(const EventArgs&)
 {
        int rc;
 
@@ -169,22 +163,18 @@ int TlsClient::WritableEventHandler(const EventArgs&)
                                m_BlockWrite = true;
                                /* fall through */
                        case SSL_ERROR_WANT_WRITE:
-                               return 0;
+                               return;
                        case SSL_ERROR_ZERO_RETURN:
                                Close();
-
-                               return 0;
+                               return;
                        default:
                                HandleSocketError(OpenSSLException(
                                    "SSL_write failed", ERR_get_error()));
-
-                               return 0;
+                               return;
                }
        }
 
        GetSendQueue()->Read(NULL, rc);
-
-       return 0;
 }
 
 /**
@@ -240,7 +230,7 @@ void TlsClient::CloseInternal(bool from_dtor)
  */
 TcpClient::Ptr icinga::TlsClientFactory(TcpClientRole role, shared_ptr<SSL_CTX> sslContext)
 {
-       return make_shared<TlsClient>(role, sslContext);
+       return boost::make_shared<TlsClient>(role, sslContext);
 }
 
 /**
index 2bc33e7277542a683e33528793b1ce3bd99fd40d..2773c0c96961d16476b39852cd0000e891c7d80a 100644 (file)
@@ -70,8 +70,8 @@ private:
        static int m_SSLIndex;
        static bool m_SSLIndexInitialized;
 
-       virtual int ReadableEventHandler(const EventArgs& ea);
-       virtual int WritableEventHandler(const EventArgs& ea);
+       virtual void ReadableEventHandler(const EventArgs& ea);
+       virtual void WritableEventHandler(const EventArgs& ea);
 
        virtual void CloseInternal(bool from_dtor);
 
index 504280c626534032ad07e6bbd552586c4d79c420..79ef54ae89c5ef7f189974bde7276a673fbf85b7 100644 (file)
@@ -28,17 +28,19 @@ string CheckerComponent::GetName(void) const
 
 void CheckerComponent::Start(void)
 {
-       m_CheckerEndpoint = make_shared<VirtualEndpoint>();
+       m_CheckerEndpoint = boost::make_shared<VirtualEndpoint>();
        m_CheckerEndpoint->RegisterTopicHandler("checker::AssignService",
-               bind(&CheckerComponent::AssignServiceRequestHandler, this, _1));
+               boost::bind(&CheckerComponent::AssignServiceRequestHandler, this, _1));
        m_CheckerEndpoint->RegisterTopicHandler("checker::RevokeService",
-               bind(&CheckerComponent::AssignServiceRequestHandler, this, _1));
+               boost::bind(&CheckerComponent::RevokeServiceRequestHandler, this, _1));
+       m_CheckerEndpoint->RegisterTopicHandler("checker::ClearServices",
+               boost::bind(&CheckerComponent::ClearServicesRequestHandler, this, _1));
        m_CheckerEndpoint->RegisterPublication("checker::CheckResult");
        GetEndpointManager()->RegisterEndpoint(m_CheckerEndpoint);
 
-       m_CheckTimer = make_shared<Timer>();
+       m_CheckTimer = boost::make_shared<Timer>();
        m_CheckTimer->SetInterval(10);
-       m_CheckTimer->OnTimerExpired.connect(bind(&CheckerComponent::CheckTimerHandler, this, _1));
+       m_CheckTimer->OnTimerExpired.connect(boost::bind(&CheckerComponent::CheckTimerHandler, this));
        m_CheckTimer->Start();
 
        CheckTask::RegisterType("nagios", NagiosCheckTask::CreateTask);
@@ -60,13 +62,13 @@ void CheckerComponent::Stop(void)
                mgr->UnregisterEndpoint(m_CheckerEndpoint);
 }
 
-int CheckerComponent::CheckTimerHandler(const TimerEventArgs& ea)
+void CheckerComponent::CheckTimerHandler(void)
 {
        time_t now;
        time(&now);
 
        if (m_Services.size() == 0)
-               return 0;
+               return;
 
        for (;;) {
                Service service = m_Services.top();
@@ -75,7 +77,7 @@ int CheckerComponent::CheckTimerHandler(const TimerEventArgs& ea)
                        break;
 
                CheckTask::Ptr ct = CheckTask::CreateTask(service);
-               Application::Log("Executing service check for '" + service.GetName() + "'");
+               Application::Log(LogInformation, "checker", "Executing service check for '" + service.GetName() + "'");
                CheckResult cr = ct->Execute();
 
                m_Services.pop();
@@ -85,47 +87,91 @@ int CheckerComponent::CheckTimerHandler(const TimerEventArgs& ea)
 
        /* adjust next call time for the check timer */
        Service service = m_Services.top();
-       static_pointer_cast<Timer>(ea.Source)->SetInterval(service.GetNextCheck() - now);
-
-       return 0;
+       m_CheckTimer->SetInterval(service.GetNextCheck() - now);
 }
 
-int CheckerComponent::AssignServiceRequestHandler(const NewRequestEventArgs& nrea)
+void CheckerComponent::AssignServiceRequestHandler(const NewRequestEventArgs& nrea)
 {
-       string id;
-       if (!nrea.Request.GetID(&id))
-               return 0;
-
        MessagePart params;
        if (!nrea.Request.GetParams(&params))
-               return 0;
+               return;
 
        MessagePart serviceMsg;
        if (!params.GetProperty("service", &serviceMsg))
-               return 0;
+               return;
 
-       ConfigObject::Ptr object = make_shared<ConfigObject>(serviceMsg.GetDictionary());
+       ConfigObject::Ptr object = boost::make_shared<ConfigObject>(serviceMsg.GetDictionary());
        Service service(object);
        m_Services.push(service);
 
-       Application::Log("Accepted service '" + service.GetName() + "'");
+       Application::Log(LogInformation, "checker", "Accepted delegation for service '" + service.GetName() + "'");
 
        /* force a service check */
        m_CheckTimer->Reschedule(0);
 
-       ResponseMessage rm;
-       rm.SetID(id);
+       string id;
+       if (nrea.Request.GetID(&id)) {
+               ResponseMessage rm;
+               rm.SetID(id);
+
+               MessagePart result;
+               rm.SetResult(result);
+               GetEndpointManager()->SendUnicastMessage(m_CheckerEndpoint, nrea.Sender, rm);
+       }
+}
+
+void CheckerComponent::RevokeServiceRequestHandler(const NewRequestEventArgs& nrea)
+{
+       MessagePart params;
+       if (!nrea.Request.GetParams(&params))
+               return;
+
+       string name;
+       if (!params.GetProperty("service", &name))
+               return;
+
+       vector<Service> services;
 
-       MessagePart result;
-       rm.SetResult(result);
-       GetEndpointManager()->SendUnicastMessage(m_CheckerEndpoint, nrea.Sender, rm);
+       while (!m_Services.empty()) {
+               Service service = m_Services.top();
+
+               if (service.GetName() == name)
+                       continue;
+
+               services.push_back(service);
+       }
 
-       return 0;
+       vector<Service>::const_iterator it;
+       for (it = services.begin(); it != services.end(); it++)
+               m_Services.push(*it);
+
+       Application::Log(LogInformation, "checker", "Revoked delegation for service '" + name + "'");
+
+       string id;
+       if (nrea.Request.GetID(&id)) {
+               ResponseMessage rm;
+               rm.SetID(id);
+
+               MessagePart result;
+               rm.SetResult(result);
+               GetEndpointManager()->SendUnicastMessage(m_CheckerEndpoint, nrea.Sender, rm);
+       }
 }
 
-int CheckerComponent::RevokeServiceRequestHandler(const NewRequestEventArgs& nrea)
+void CheckerComponent::ClearServicesRequestHandler(const NewRequestEventArgs& nrea)
 {
-       return 0;
+       Application::Log(LogInformation, "checker", "Clearing service delegations.");
+       m_Services = ServiceQueue();
+
+       string id;
+       if (nrea.Request.GetID(&id)) {
+               ResponseMessage rm;
+               rm.SetID(id);
+
+               MessagePart result;
+               rm.SetResult(result);
+               GetEndpointManager()->SendUnicastMessage(m_CheckerEndpoint, nrea.Sender, rm);
+       }
 }
 
 EXPORT_COMPONENT(checker, CheckerComponent);
index 4198ad1730407c7f62a7347ef5da87b4e83d1f73..7dca5ccce53c06c6ab873e13d7e424278f0190b1 100644 (file)
@@ -38,19 +38,25 @@ public:
 class CheckerComponent : public IcingaComponent
 {
 public:
+       typedef shared_ptr<CheckerComponent> Ptr;
+       typedef weak_ptr<CheckerComponent> WeakPtr;
+
+       typedef priority_queue<Service, vector<Service>, ServiceNextCheckLessComparer> ServiceQueue;
+
        virtual string GetName(void) const;
        virtual void Start(void);
        virtual void Stop(void);
 
 private:
-       priority_queue<Service, vector<Service>, ServiceNextCheckLessComparer> m_Services;
+       ServiceQueue m_Services;
        Timer::Ptr m_CheckTimer;
        VirtualEndpoint::Ptr m_CheckerEndpoint;
 
-       int CheckTimerHandler(const TimerEventArgs& ea);
+       void CheckTimerHandler(void);
 
-       int AssignServiceRequestHandler(const NewRequestEventArgs& nrea);
-       int RevokeServiceRequestHandler(const NewRequestEventArgs& nrea);
+       void AssignServiceRequestHandler(const NewRequestEventArgs& nrea);
+       void RevokeServiceRequestHandler(const NewRequestEventArgs& nrea);
+       void ClearServicesRequestHandler(const NewRequestEventArgs& nrea);
 };
 
 }
index fc804eddea45128d9d286a1fe4b13f32c6c52a38..8a0ad53de2b9759acd168793a8d9217432cf491c 100644 (file)
@@ -31,6 +31,8 @@
 
 #include <queue>
 
+using std::priority_queue;
+
 #include "checkercomponent.h"
 
 #endif /* I2CHECKER_H */
index c7f04a2c8bdf9ecab5d9f608cf94257564550ae2..ac6e92a572b6a20b073b02dbbb9b3ad83d3c7f80 100644 (file)
@@ -19,6 +19,8 @@
 
 #include "i2-configfile.h"
 
+using std::ifstream;
+
 using namespace icinga;
 
 string ConfigFileComponent::GetName(void) const
@@ -29,17 +31,17 @@ string ConfigFileComponent::GetName(void) const
 void ConfigFileComponent::Start(void)
 {
        ifstream fp;
-       FIFO::Ptr fifo = make_shared<FIFO>();
+       FIFO::Ptr fifo = boost::make_shared<FIFO>();
 
        string filename;
        if (!GetConfig()->GetProperty("configFilename", &filename))
                throw logic_error("Missing 'configFilename' property");
 
-       Application::Log("Compiling config file: " + filename);
+       Application::Log(LogInformation, "configfile", "Compiling config file: " + filename);
 
        vector<ConfigItem::Ptr> configItems = ConfigCompiler::CompileFile(filename);
 
-       Application::Log("Executing config items...");
+       Application::Log(LogInformation, "configfile", "Executing config items...");
 
        ConfigVM::ExecuteItems(configItems);
 }
index b9fbf8f2f68de191a24ef3befe4ace4b78e58a72..38ae78d31ea68628901b545d3d8e28e47e4695f7 100644 (file)
@@ -30,28 +30,28 @@ void ConfigRpcComponent::Start(void)
 {
        EndpointManager::Ptr endpointManager = GetEndpointManager();
 
-       m_ConfigRpcEndpoint = make_shared<VirtualEndpoint>();
+       m_ConfigRpcEndpoint = boost::make_shared<VirtualEndpoint>();
 
        long configSource;
        if (GetConfig()->GetProperty("configSource", &configSource) && configSource != 0) {
                m_ConfigRpcEndpoint->RegisterTopicHandler("config::FetchObjects",
-                   bind(&ConfigRpcComponent::FetchObjectsHandler, this, _1));
+                   boost::bind(&ConfigRpcComponent::FetchObjectsHandler, this, _1));
 
-               ConfigObject::GetAllObjects()->OnObjectAdded.connect(bind(&ConfigRpcComponent::LocalObjectCommittedHandler, this, _1));
-               ConfigObject::GetAllObjects()->OnObjectCommitted.connect(bind(&ConfigRpcComponent::LocalObjectCommittedHandler, this, _1));
-               ConfigObject::GetAllObjects()->OnObjectRemoved.connect(bind(&ConfigRpcComponent::LocalObjectRemovedHandler, this, _1));
+               ConfigObject::GetAllObjects()->OnObjectAdded.connect(boost::bind(&ConfigRpcComponent::LocalObjectCommittedHandler, this, _1));
+               ConfigObject::GetAllObjects()->OnObjectCommitted.connect(boost::bind(&ConfigRpcComponent::LocalObjectCommittedHandler, this, _1));
+               ConfigObject::GetAllObjects()->OnObjectRemoved.connect(boost::bind(&ConfigRpcComponent::LocalObjectRemovedHandler, this, _1));
 
                m_ConfigRpcEndpoint->RegisterPublication("config::ObjectCommitted");
                m_ConfigRpcEndpoint->RegisterPublication("config::ObjectRemoved");
        }
 
-       endpointManager->OnNewEndpoint.connect(bind(&ConfigRpcComponent::NewEndpointHandler, this, _1));
+       endpointManager->OnNewEndpoint.connect(boost::bind(&ConfigRpcComponent::NewEndpointHandler, this, _1));
 
        m_ConfigRpcEndpoint->RegisterPublication("config::FetchObjects");
        m_ConfigRpcEndpoint->RegisterTopicHandler("config::ObjectCommitted",
-           bind(&ConfigRpcComponent::RemoteObjectCommittedHandler, this, _1));
+           boost::bind(&ConfigRpcComponent::RemoteObjectCommittedHandler, this, _1));
        m_ConfigRpcEndpoint->RegisterTopicHandler("config::ObjectRemoved",
-           bind(&ConfigRpcComponent::RemoteObjectRemovedHandler, this, _1));
+           boost::bind(&ConfigRpcComponent::RemoteObjectRemovedHandler, this, _1));
 
        endpointManager->RegisterEndpoint(m_ConfigRpcEndpoint);
 }
@@ -64,22 +64,18 @@ void ConfigRpcComponent::Stop(void)
                mgr->UnregisterEndpoint(m_ConfigRpcEndpoint);
 }
 
-int ConfigRpcComponent::NewEndpointHandler(const NewEndpointEventArgs& ea)
+void ConfigRpcComponent::NewEndpointHandler(const NewEndpointEventArgs& ea)
 {
-       ea.Endpoint->OnSessionEstablished.connect(bind(&ConfigRpcComponent::SessionEstablishedHandler, this, _1));
-
-       return 0;
+       ea.Endpoint->OnSessionEstablished.connect(boost::bind(&ConfigRpcComponent::SessionEstablishedHandler, this, _1));
 }
 
-int ConfigRpcComponent::SessionEstablishedHandler(const EventArgs& ea)
+void ConfigRpcComponent::SessionEstablishedHandler(const EventArgs& ea)
 {
        RequestMessage request;
        request.SetMethod("config::FetchObjects");
 
        Endpoint::Ptr endpoint = static_pointer_cast<Endpoint>(ea.Source);
        GetEndpointManager()->SendUnicastMessage(m_ConfigRpcEndpoint, endpoint, request);
-
-       return 0;
 }
 
 RequestMessage ConfigRpcComponent::MakeObjectMessage(const ConfigObject::Ptr& object, string method, bool includeProperties)
@@ -104,7 +100,7 @@ bool ConfigRpcComponent::ShouldReplicateObject(const ConfigObject::Ptr& object)
        return (!object->IsLocal());
 }
 
-int ConfigRpcComponent::FetchObjectsHandler(const NewRequestEventArgs& ea)
+void ConfigRpcComponent::FetchObjectsHandler(const NewRequestEventArgs& ea)
 {
        Endpoint::Ptr client = ea.Sender;
        ConfigObject::Set::Ptr allObjects = ConfigObject::GetAllObjects();
@@ -119,93 +115,83 @@ int ConfigRpcComponent::FetchObjectsHandler(const NewRequestEventArgs& ea)
 
                GetEndpointManager()->SendUnicastMessage(m_ConfigRpcEndpoint, client, request);
        }
-
-       return 0;
 }
 
-int ConfigRpcComponent::LocalObjectCommittedHandler(const ObjectSetEventArgs<ConfigObject::Ptr>& ea)
+void ConfigRpcComponent::LocalObjectCommittedHandler(const ObjectSetEventArgs<ConfigObject::Ptr>& ea)
 {
        ConfigObject::Ptr object = ea.Target;
        
        if (!ShouldReplicateObject(object))
-               return 0;
+               return;
 
        GetEndpointManager()->SendMulticastMessage(m_ConfigRpcEndpoint,
            MakeObjectMessage(object, "config::ObjectCreated", true));
-
-       return 0;
 }
 
-int ConfigRpcComponent::LocalObjectRemovedHandler(const ObjectSetEventArgs<ConfigObject::Ptr>& ea)
+void ConfigRpcComponent::LocalObjectRemovedHandler(const ObjectSetEventArgs<ConfigObject::Ptr>& ea)
 {
        ConfigObject::Ptr object = ea.Target;
        
        if (!ShouldReplicateObject(object))
-               return 0;
+               return;
 
        GetEndpointManager()->SendMulticastMessage(m_ConfigRpcEndpoint,
            MakeObjectMessage(object, "config::ObjectRemoved", false));
-
-       return 0;
 }
 
-int ConfigRpcComponent::RemoteObjectCommittedHandler(const NewRequestEventArgs& ea)
+void ConfigRpcComponent::RemoteObjectCommittedHandler(const NewRequestEventArgs& ea)
 {
        RequestMessage message = ea.Request;
 
        MessagePart params;
        if (!message.GetParams(&params))
-               return 0;
+               return;
 
        string name;
        if (!params.GetProperty("name", &name))
-               return 0;
+               return;
 
        string type;
        if (!params.GetProperty("type", &type))
-               return 0;
+               return;
 
        MessagePart properties;
        if (!params.GetProperty("properties", &properties))
-               return 0;
+               return;
 
        ConfigObject::Ptr object = ConfigObject::GetObject(type, name);
 
        if (!object)
-               object = make_shared<ConfigObject>(properties.GetDictionary());
+               object = boost::make_shared<ConfigObject>(properties.GetDictionary());
        else
                object->SetProperties(properties.GetDictionary());
 
        object->Commit();
-
-       return 0;
 }
 
-int ConfigRpcComponent::RemoteObjectRemovedHandler(const NewRequestEventArgs& ea)
+void ConfigRpcComponent::RemoteObjectRemovedHandler(const NewRequestEventArgs& ea)
 {
        RequestMessage message = ea.Request;
        
        MessagePart params;
        if (!message.GetParams(&params))
-               return 0;
+               return;
 
        string name;
        if (!params.GetProperty("name", &name))
-               return 0;
+               return;
 
        string type;
        if (!params.GetProperty("type", &type))
-               return 0;
+               return;
 
        ConfigObject::Ptr object = ConfigObject::GetObject(type, name);
 
        if (!object)
-               return 0;
+               return;
 
        if (!object->IsLocal())
                object->Unregister();
-
-       return 0;
 }
 
 EXPORT_COMPONENT(configrpc, ConfigRpcComponent);
index 2ae882d6a46f6476a8b5214c3e0aa577f852c8b6..35d9fd875fd479ef66e27d023c61a07fbdd315cb 100644 (file)
@@ -36,15 +36,15 @@ public:
 private:
        VirtualEndpoint::Ptr m_ConfigRpcEndpoint;
 
-       int NewEndpointHandler(const NewEndpointEventArgs& ea);
-       int SessionEstablishedHandler(const EventArgs& ea);
+       void NewEndpointHandler(const NewEndpointEventArgs& ea);
+       void SessionEstablishedHandler(const EventArgs& ea);
 
-       int LocalObjectCommittedHandler(const ObjectSetEventArgs<ConfigObject::Ptr>& ea);
-       int LocalObjectRemovedHandler(const ObjectSetEventArgs<ConfigObject::Ptr>& ea);
+       void LocalObjectCommittedHandler(const ObjectSetEventArgs<ConfigObject::Ptr>& ea);
+       void LocalObjectRemovedHandler(const ObjectSetEventArgs<ConfigObject::Ptr>& ea);
 
-       int FetchObjectsHandler(const NewRequestEventArgs& ea);
-       int RemoteObjectCommittedHandler(const NewRequestEventArgs& ea);
-       int RemoteObjectRemovedHandler(const NewRequestEventArgs& ea);
+       void FetchObjectsHandler(const NewRequestEventArgs& ea);
+       void RemoteObjectCommittedHandler(const NewRequestEventArgs& ea);
+       void RemoteObjectRemovedHandler(const NewRequestEventArgs& ea);
 
        static RequestMessage MakeObjectMessage(const ConfigObject::Ptr& object,
            string method, bool includeProperties);
index f68a896d3fb58263d7f7d9b008041062b99a130f..91cf711568a31b808ff4bb911fe17658b69a7e7a 100644 (file)
@@ -28,18 +28,18 @@ string DelegationComponent::GetName(void) const
 
 void DelegationComponent::Start(void)
 {
-       m_AllServices = make_shared<ConfigObject::Set>(ConfigObject::GetAllObjects(), ConfigObject::MakeTypePredicate("service"));
-       m_AllServices->OnObjectAdded.connect(bind(&DelegationComponent::NewServiceHandler, this, _1));
-       m_AllServices->OnObjectCommitted.connect(bind(&DelegationComponent::NewServiceHandler, this, _1));
-       m_AllServices->OnObjectRemoved.connect(bind(&DelegationComponent::RemovedServiceHandler, this, _1));
+       m_AllServices = boost::make_shared<ConfigObject::Set>(ConfigObject::GetAllObjects(), ConfigObject::MakeTypePredicate("service"));
+       m_AllServices->OnObjectAdded.connect(boost::bind(&DelegationComponent::NewServiceHandler, this, _1));
+       m_AllServices->OnObjectCommitted.connect(boost::bind(&DelegationComponent::NewServiceHandler, this, _1));
+       m_AllServices->OnObjectRemoved.connect(boost::bind(&DelegationComponent::RemovedServiceHandler, this, _1));
        m_AllServices->Start();
 
-       m_DelegationTimer = make_shared<Timer>();
+       m_DelegationTimer = boost::make_shared<Timer>();
        m_DelegationTimer->SetInterval(30);
-       m_DelegationTimer->OnTimerExpired.connect(bind(&DelegationComponent::DelegationTimerHandler, this, _1));
+       m_DelegationTimer->OnTimerExpired.connect(boost::bind(&DelegationComponent::DelegationTimerHandler, this));
        m_DelegationTimer->Start();
 
-       m_DelegationEndpoint = make_shared<VirtualEndpoint>();
+       m_DelegationEndpoint = boost::make_shared<VirtualEndpoint>();
        m_DelegationEndpoint->RegisterPublication("checker::AssignService");
        m_DelegationEndpoint->RegisterPublication("checker::RevokeService");
        GetEndpointManager()->RegisterEndpoint(m_DelegationEndpoint);
@@ -53,16 +53,14 @@ void DelegationComponent::Stop(void)
                mgr->UnregisterEndpoint(m_DelegationEndpoint);
 }
 
-int DelegationComponent::NewServiceHandler(const ObjectSetEventArgs<ConfigObject::Ptr>& ea)
+void DelegationComponent::NewServiceHandler(const ObjectSetEventArgs<ConfigObject::Ptr>& ea)
 {
        AssignService(ea.Target);
-       return 0;
 }
 
-int DelegationComponent::RemovedServiceHandler(const ObjectSetEventArgs<ConfigObject::Ptr>& ea)
+void DelegationComponent::RemovedServiceHandler(const ObjectSetEventArgs<ConfigObject::Ptr>& ea)
 {
        RevokeService(ea.Target);
-       return 0;
 }
 
 void DelegationComponent::AssignService(const ConfigObject::Ptr& service)
@@ -74,22 +72,20 @@ void DelegationComponent::AssignService(const ConfigObject::Ptr& service)
        params.SetProperty("service", service->GetProperties());
        request.SetParams(params);
 
-       Application::Log("Trying to delegate service '" + service->GetName() + "'");
+       Application::Log(LogInformation, "delegation", "Trying to delegate service '" + service->GetName() + "'");
 
        GetEndpointManager()->SendAPIMessage(m_DelegationEndpoint, request,
-           bind(&DelegationComponent::AssignServiceResponseHandler, this, service, _1));
+           boost::bind(&DelegationComponent::AssignServiceResponseHandler, this, service, _1));
 }
 
-int DelegationComponent::AssignServiceResponseHandler(const ConfigObject::Ptr& service, const NewResponseEventArgs& nrea)
+void DelegationComponent::AssignServiceResponseHandler(const ConfigObject::Ptr& service, const NewResponseEventArgs& nrea)
 {
        if (nrea.TimedOut) {
-               Application::Log("Service delegation for service '" + service->GetName() + "' timed out.");
+               Application::Log(LogInformation, "delegation", "Service delegation for service '" + service->GetName() + "' timed out.");
        } else {
                service->SetTag("checker", nrea.Sender->GetIdentity());
-               Application::Log("Service delegation for service '" + service->GetName() + "' was successful.");
+               Application::Log(LogInformation, "delegation", "Service delegation for service '" + service->GetName() + "' was successful.");
        }
-
-       return 0;
 }
 
 void DelegationComponent::RevokeService(const ConfigObject::Ptr& service)
@@ -97,12 +93,11 @@ void DelegationComponent::RevokeService(const ConfigObject::Ptr& service)
 
 }
 
-int DelegationComponent::RevokeServiceResponseHandler(const NewResponseEventArgs& nrea)
+void DelegationComponent::RevokeServiceResponseHandler(const NewResponseEventArgs& nrea)
 {
-       return 0;
 }
 
-int DelegationComponent::DelegationTimerHandler(const TimerEventArgs& ea)
+void DelegationComponent::DelegationTimerHandler(void)
 {
        ConfigObject::Set::Iterator it;
        for (it = m_AllServices->Begin(); it != m_AllServices->End(); it++) {
@@ -114,15 +109,6 @@ int DelegationComponent::DelegationTimerHandler(const TimerEventArgs& ea)
 
                AssignService(object);
        }
-
-       return 0;
-}
-
-int DelegationComponent::TestResponseHandler(const NewResponseEventArgs& ea)
-{
-       Application::Log("Response handler called.");
-
-       return 0;
 }
 
 EXPORT_COMPONENT(delegation, DelegationComponent);
index b4221b28e01795a0e68b3c96cb6dea40f671ecdb..db80707016d94d17c3bfe4168bc494894b46d560 100644 (file)
@@ -38,18 +38,16 @@ private:
        ConfigObject::Set::Ptr m_AllServices;
        Timer::Ptr m_DelegationTimer;
 
-       int NewServiceHandler(const ObjectSetEventArgs<ConfigObject::Ptr>& ea);
-       int RemovedServiceHandler(const ObjectSetEventArgs<ConfigObject::Ptr>& ea);
+       void NewServiceHandler(const ObjectSetEventArgs<ConfigObject::Ptr>& ea);
+       void RemovedServiceHandler(const ObjectSetEventArgs<ConfigObject::Ptr>& ea);
 
-       int AssignServiceResponseHandler(const ConfigObject::Ptr& service, const NewResponseEventArgs& nrea);
-       int RevokeServiceResponseHandler(const NewResponseEventArgs& nrea);
+       void AssignServiceResponseHandler(const ConfigObject::Ptr& service, const NewResponseEventArgs& nrea);
+       void RevokeServiceResponseHandler(const NewResponseEventArgs& nrea);
 
-       int DelegationTimerHandler(const TimerEventArgs& ea);
+       void DelegationTimerHandler(void);
 
        void AssignService(const ConfigObject::Ptr& service);
        void RevokeService(const ConfigObject::Ptr& service);
-
-       int TestResponseHandler(const NewResponseEventArgs& ea);
 };
 
 }
index ce8449be25d85a4d7fd02bbaa3fca0708bb83052..f08272ec21740eb23dc0c925fc8ef8d31bd3c495 100644 (file)
@@ -36,15 +36,15 @@ string DemoComponent::GetName(void) const
  */
 void DemoComponent::Start(void)
 {
-       m_DemoEndpoint = make_shared<VirtualEndpoint>();
+       m_DemoEndpoint = boost::make_shared<VirtualEndpoint>();
        m_DemoEndpoint->RegisterTopicHandler("demo::HelloWorld",
-           bind(&DemoComponent::HelloWorldRequestHandler, this, _1));
+           boost::bind(&DemoComponent::HelloWorldRequestHandler, this, _1));
        m_DemoEndpoint->RegisterPublication("demo::HelloWorld");
        GetEndpointManager()->RegisterEndpoint(m_DemoEndpoint);
 
-       m_DemoTimer = make_shared<Timer>();
+       m_DemoTimer = boost::make_shared<Timer>();
        m_DemoTimer->SetInterval(5);
-       m_DemoTimer->OnTimerExpired.connect(bind(&DemoComponent::DemoTimerHandler, this, _1));
+       m_DemoTimer->OnTimerExpired.connect(boost::bind(&DemoComponent::DemoTimerHandler, this));
        m_DemoTimer->Start();
 }
 
@@ -65,29 +65,24 @@ void DemoComponent::Stop(void)
  * Periodically sends a demo::HelloWorld message.
  *
  * @param - Event arguments for the timer.
- * @returns 0
  */
-int DemoComponent::DemoTimerHandler(const TimerEventArgs&)
+void DemoComponent::DemoTimerHandler(void)
 {
-       Application::Log("Sending multicast 'hello world' message.");
+       Application::Log(LogInformation, "demo", "Sending multicast 'hello world' message.");
 
        RequestMessage request;
        request.SetMethod("demo::HelloWorld");
 
        EndpointManager::Ptr endpointManager = GetIcingaApplication()->GetEndpointManager();
        endpointManager->SendMulticastMessage(m_DemoEndpoint, request);
-
-       return 0;
 }
 
 /**
  * Processes demo::HelloWorld messages.
  */
-int DemoComponent::HelloWorldRequestHandler(const NewRequestEventArgs& nrea)
+void DemoComponent::HelloWorldRequestHandler(const NewRequestEventArgs& nrea)
 {
-       Application::Log("Got 'hello world' from address=" + nrea.Sender->GetAddress() + ", identity=" + nrea.Sender->GetIdentity());
-
-       return 0;
+       Application::Log(LogInformation, "demo", "Got 'hello world' from address=" + nrea.Sender->GetAddress() + ", identity=" + nrea.Sender->GetIdentity());
 }
 
 EXPORT_COMPONENT(demo, DemoComponent);
index a9334b3414b5dfb77e53a1c1e66173911e90eb4a..e6341558f9c4232d4e101728b61daf2297da7259 100644 (file)
@@ -37,8 +37,8 @@ private:
        Timer::Ptr m_DemoTimer;
        VirtualEndpoint::Ptr m_DemoEndpoint;
 
-       int DemoTimerHandler(const TimerEventArgs& tea);
-       int HelloWorldRequestHandler(const NewRequestEventArgs& nrea);
+       void DemoTimerHandler(void);
+       void HelloWorldRequestHandler(const NewRequestEventArgs& nrea);
 };
 
 }
index 616f2791ba915fe5cf752d862d4fe24e6d0c9c2d..1bf293c6b28e81d33fbef566f0221a83822dfea3 100644 (file)
@@ -36,28 +36,28 @@ string DiscoveryComponent::GetName(void) const
  */
 void DiscoveryComponent::Start(void)
 {
-       m_DiscoveryEndpoint = make_shared<VirtualEndpoint>();
+       m_DiscoveryEndpoint = boost::make_shared<VirtualEndpoint>();
 
        m_DiscoveryEndpoint->RegisterPublication("discovery::RegisterComponent");
        m_DiscoveryEndpoint->RegisterTopicHandler("discovery::RegisterComponent",
-               bind(&DiscoveryComponent::RegisterComponentMessageHandler, this, _1));
+               boost::bind(&DiscoveryComponent::RegisterComponentMessageHandler, this, _1));
 
        m_DiscoveryEndpoint->RegisterPublication("discovery::NewComponent");
        m_DiscoveryEndpoint->RegisterTopicHandler("discovery::NewComponent",
-               bind(&DiscoveryComponent::NewComponentMessageHandler, this, _1));
+               boost::bind(&DiscoveryComponent::NewComponentMessageHandler, this, _1));
 
        m_DiscoveryEndpoint->RegisterTopicHandler("discovery::Welcome",
-               bind(&DiscoveryComponent::WelcomeMessageHandler, this, _1));
+               boost::bind(&DiscoveryComponent::WelcomeMessageHandler, this, _1));
 
-       GetEndpointManager()->ForEachEndpoint(bind(&DiscoveryComponent::NewEndpointHandler, this, _1));
-       GetEndpointManager()->OnNewEndpoint.connect(bind(&DiscoveryComponent::NewEndpointHandler, this, _1));
+       GetEndpointManager()->ForEachEndpoint(boost::bind(&DiscoveryComponent::NewEndpointHandler, this, _1));
+       GetEndpointManager()->OnNewEndpoint.connect(boost::bind(&DiscoveryComponent::NewEndpointHandler, this, _1));
 
        GetEndpointManager()->RegisterEndpoint(m_DiscoveryEndpoint);
 
        /* create the reconnect timer */
-       m_DiscoveryTimer = make_shared<Timer>();
+       m_DiscoveryTimer = boost::make_shared<Timer>();
        m_DiscoveryTimer->SetInterval(30);
-       m_DiscoveryTimer->OnTimerExpired.connect(bind(&DiscoveryComponent::DiscoveryTimerHandler, this, _1));
+       m_DiscoveryTimer->OnTimerExpired.connect(boost::bind(&DiscoveryComponent::DiscoveryTimerHandler, this));
        m_DiscoveryTimer->Start();
 
        /* call the timer as soon as possible */
@@ -81,24 +81,21 @@ void DiscoveryComponent::Stop(void)
  *
  * @param endpoint The endpoint that is to be checked.
  * @param neea Event arguments for another endpoint.
- * @returns 0
  */
-int DiscoveryComponent::CheckExistingEndpoint(Endpoint::Ptr endpoint, const NewEndpointEventArgs& neea)
+void DiscoveryComponent::CheckExistingEndpoint(Endpoint::Ptr endpoint, const NewEndpointEventArgs& neea)
 {
        if (endpoint == neea.Endpoint)
-               return 0;
+               return;
 
        if (!neea.Endpoint->IsConnected())
-               return 0;
+               return;
 
        if (endpoint->GetIdentity() == neea.Endpoint->GetIdentity()) {
-               Application::Log("Detected duplicate identity:" + endpoint->GetIdentity() + " - Disconnecting old endpoint.");
+               Application::Log(LogWarning, "discovery", "Detected duplicate identity:" + endpoint->GetIdentity() + " - Disconnecting old endpoint.");
 
                neea.Endpoint->Stop();
                GetEndpointManager()->UnregisterEndpoint(neea.Endpoint);
        }
-
-       return 0;
 }
 
 /**
@@ -107,17 +104,15 @@ int DiscoveryComponent::CheckExistingEndpoint(Endpoint::Ptr endpoint, const NewE
  * @param neea Event arguments for the new endpoint.
  * @returns 0
  */
-int DiscoveryComponent::NewEndpointHandler(const NewEndpointEventArgs& neea)
+void DiscoveryComponent::NewEndpointHandler(const NewEndpointEventArgs& neea)
 {
-       neea.Endpoint->OnIdentityChanged.connect(bind(&DiscoveryComponent::NewIdentityHandler, this, _1));
+       neea.Endpoint->OnIdentityChanged.connect(boost::bind(&DiscoveryComponent::NewIdentityHandler, this, _1));
 
        /* accept discovery::RegisterComponent messages from any endpoint */
        neea.Endpoint->RegisterPublication("discovery::RegisterComponent");
 
        /* accept discovery::Welcome messages from any endpoint */
        neea.Endpoint->RegisterPublication("discovery::Welcome");
-
-       return 0;
 }
 
 /**
@@ -127,7 +122,7 @@ int DiscoveryComponent::NewEndpointHandler(const NewEndpointEventArgs& neea)
  * @param info Component information object.
  * @return 0
  */
-int DiscoveryComponent::DiscoveryEndpointHandler(const NewEndpointEventArgs& neea, ComponentDiscoveryInfo::Ptr info) const
+void DiscoveryComponent::DiscoveryEndpointHandler(const NewEndpointEventArgs& neea, ComponentDiscoveryInfo::Ptr info) const
 {
        Endpoint::ConstTopicIterator i;
 
@@ -138,8 +133,6 @@ int DiscoveryComponent::DiscoveryEndpointHandler(const NewEndpointEventArgs& nee
        for (i = neea.Endpoint->BeginPublications(); i != neea.Endpoint->EndPublications(); i++) {
                info->Publications.insert(*i);
        }
-
-       return 0;
 }
 
 /**
@@ -153,8 +146,8 @@ bool DiscoveryComponent::GetComponentDiscoveryInfo(string component, ComponentDi
 {
        if (component == GetEndpointManager()->GetIdentity()) {
                /* Build fake discovery info for ourselves */
-               *info = make_shared<ComponentDiscoveryInfo>();
-               GetEndpointManager()->ForEachEndpoint(bind(&DiscoveryComponent::DiscoveryEndpointHandler, this, _1, *info));
+               *info = boost::make_shared<ComponentDiscoveryInfo>();
+               GetEndpointManager()->ForEachEndpoint(boost::bind(&DiscoveryComponent::DiscoveryEndpointHandler, this, _1, *info));
                
                (*info)->LastSeen = 0;
                (*info)->Node = GetIcingaApplication()->GetNode();
@@ -180,21 +173,21 @@ bool DiscoveryComponent::GetComponentDiscoveryInfo(string component, ComponentDi
  * @param ea Event arguments for the component.
  * @returns 0
  */
-int DiscoveryComponent::NewIdentityHandler(const EventArgs& ea)
+void DiscoveryComponent::NewIdentityHandler(const EventArgs& ea)
 {
        Endpoint::Ptr endpoint = static_pointer_cast<Endpoint>(ea.Source);
        string identity = endpoint->GetIdentity();
 
        if (identity == GetEndpointManager()->GetIdentity()) {
-               Application::Log("Detected loop-back connection - Disconnecting endpoint.");
+               Application::Log(LogWarning, "discovery", "Detected loop-back connection - Disconnecting endpoint.");
 
                endpoint->Stop();
                GetEndpointManager()->UnregisterEndpoint(endpoint);
 
-               return 0;
+               return;
        }
 
-       GetEndpointManager()->ForEachEndpoint(bind(&DiscoveryComponent::CheckExistingEndpoint, this, endpoint, _1));
+       GetEndpointManager()->ForEachEndpoint(boost::bind(&DiscoveryComponent::CheckExistingEndpoint, this, endpoint, _1));
 
        // we assume the other component _always_ wants
        // discovery::RegisterComponent messages from us
@@ -227,7 +220,7 @@ int DiscoveryComponent::NewIdentityHandler(const EventArgs& ea)
                // we don't know the other component yet, so
                // wait until we get a discovery::NewComponent message
                // from a broker
-               return 0;
+               return;
        }
 
        // register published/subscribed topics for this endpoint
@@ -240,8 +233,6 @@ int DiscoveryComponent::NewIdentityHandler(const EventArgs& ea)
                endpoint->RegisterSubscription(*it);
 
        FinishDiscoverySetup(endpoint);
-
-       return 0;
 }
 
 /**
@@ -250,12 +241,12 @@ int DiscoveryComponent::NewIdentityHandler(const EventArgs& ea)
  * @param nrea Event arguments for the request.
  * @returns 0
  */
-int DiscoveryComponent::WelcomeMessageHandler(const NewRequestEventArgs& nrea)
+void DiscoveryComponent::WelcomeMessageHandler(const NewRequestEventArgs& nrea)
 {
        Endpoint::Ptr endpoint = nrea.Sender;
 
        if (endpoint->HasReceivedWelcome())
-               return 0;
+               return;
 
        endpoint->SetReceivedWelcome(true);
 
@@ -264,8 +255,6 @@ int DiscoveryComponent::WelcomeMessageHandler(const NewRequestEventArgs& nrea)
                ea.Source = endpoint;
                endpoint->OnSessionEstablished(ea);
        }
-
-       return 0;
 }
 
 /**
@@ -384,7 +373,7 @@ void DiscoveryComponent::ProcessDiscoveryMessage(string identity, DiscoveryMessa
        if (identity == GetEndpointManager()->GetIdentity())
                return;
 
-       ComponentDiscoveryInfo::Ptr info = make_shared<ComponentDiscoveryInfo>();
+       ComponentDiscoveryInfo::Ptr info = boost::make_shared<ComponentDiscoveryInfo>();
 
        time(&(info->LastSeen));
 
@@ -448,44 +437,36 @@ void DiscoveryComponent::ProcessDiscoveryMessage(string identity, DiscoveryMessa
  * Processes "discovery::NewComponent" messages.
  *
  * @param nrea Event arguments for the request.
- * @returns 0
  */
-int DiscoveryComponent::NewComponentMessageHandler(const NewRequestEventArgs& nrea)
+void DiscoveryComponent::NewComponentMessageHandler(const NewRequestEventArgs& nrea)
 {
        DiscoveryMessage message;
        nrea.Request.GetParams(&message);
 
        string identity;
        if (!message.GetIdentity(&identity))
-               return 0;
+               return;
 
        ProcessDiscoveryMessage(identity, message, true);
-       return 0;
 }
 
 /**
  * Processes "discovery::RegisterComponent" messages.
  *
  * @param nrea Event arguments for the request.
- * @returns 0
  */
-int DiscoveryComponent::RegisterComponentMessageHandler(const NewRequestEventArgs& nrea)
+void DiscoveryComponent::RegisterComponentMessageHandler(const NewRequestEventArgs& nrea)
 {
        DiscoveryMessage message;
        nrea.Request.GetParams(&message);
        ProcessDiscoveryMessage(nrea.Sender->GetIdentity(), message, false);
-
-       return 0;
 }
 
 /**
  * Checks whether we have to reconnect to other components and removes stale
  * components from the registry.
- *
- * @param tea Event arguments for the timer.
- * @returns 0
  */
-int DiscoveryComponent::DiscoveryTimerHandler(const TimerEventArgs& tea)
+void DiscoveryComponent::DiscoveryTimerHandler(void)
 {
        EndpointManager::Ptr endpointManager = GetEndpointManager();
        
@@ -537,8 +518,6 @@ int DiscoveryComponent::DiscoveryTimerHandler(const TimerEventArgs& tea)
                        endpointManager->AddConnection(info->Node, info->Service);
                }
        }
-
-       return 0;
 }
 
 EXPORT_COMPONENT(discovery, DiscoveryComponent);
index 75bc0ea5eb9bc0bf77283dfb6d765aba507211ff..3e3ec83a9034f4ba0633824d94a97b4768259e0c 100644 (file)
@@ -56,23 +56,23 @@ private:
        map<string, ComponentDiscoveryInfo::Ptr> m_Components;
        Timer::Ptr m_DiscoveryTimer;
 
-       int NewEndpointHandler(const NewEndpointEventArgs& neea);
-       int NewIdentityHandler(const EventArgs& ea);
+       void NewEndpointHandler(const NewEndpointEventArgs& neea);
+       void NewIdentityHandler(const EventArgs& ea);
 
-       int NewComponentMessageHandler(const NewRequestEventArgs& nrea);
-       int RegisterComponentMessageHandler(const NewRequestEventArgs& nrea);
+       void NewComponentMessageHandler(const NewRequestEventArgs& nrea);
+       void RegisterComponentMessageHandler(const NewRequestEventArgs& nrea);
 
-       int WelcomeMessageHandler(const NewRequestEventArgs& nrea);
+       void WelcomeMessageHandler(const NewRequestEventArgs& nrea);
 
        void SendDiscoveryMessage(string method, string identity, Endpoint::Ptr recipient);
        void ProcessDiscoveryMessage(string identity, DiscoveryMessage message, bool trusted);
 
        bool GetComponentDiscoveryInfo(string component, ComponentDiscoveryInfo::Ptr *info) const;
 
-       int CheckExistingEndpoint(Endpoint::Ptr endpoint, const NewEndpointEventArgs& neea);
-       int DiscoveryEndpointHandler(const NewEndpointEventArgs& neea, ComponentDiscoveryInfo::Ptr info) const;
+       void CheckExistingEndpoint(Endpoint::Ptr endpoint, const NewEndpointEventArgs& neea);
+       void DiscoveryEndpointHandler(const NewEndpointEventArgs& neea, ComponentDiscoveryInfo::Ptr info) const;
 
-       int DiscoveryTimerHandler(const TimerEventArgs& tea);
+       void DiscoveryTimerHandler(void);
 
        void FinishDiscoverySetup(Endpoint::Ptr endpoint);
 
diff --git a/config/ax_cxx_compile_stdcxx_0x.m4 b/config/ax_cxx_compile_stdcxx_0x.m4
deleted file mode 100644 (file)
index 1390ee5..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-# ============================================================================
-#  http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_0x.html
-# ============================================================================
-#
-# SYNOPSIS
-#
-#   AX_CXX_COMPILE_STDCXX_0X
-#
-# DESCRIPTION
-#
-#   Check for baseline language coverage in the compiler for the C++0x
-#   standard.
-#
-# LICENSE
-#
-#   Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
-#
-#   Copying and distribution of this file, with or without modification, are
-#   permitted in any medium without royalty provided the copyright notice
-#   and this notice are preserved. This file is offered as-is, without any
-#   warranty.
-
-#serial 7
-
-AU_ALIAS([AC_CXX_COMPILE_STDCXX_0X], [AX_CXX_COMPILE_STDCXX_0X])
-AC_DEFUN([AX_CXX_COMPILE_STDCXX_0X], [
-  AC_CACHE_CHECK(if g++ supports C++0x features without additional flags,
-  ax_cv_cxx_compile_cxx0x_native,
-  [AC_LANG_SAVE
-  AC_LANG_CPLUSPLUS
-  AC_TRY_COMPILE([
-  template <typename T>
-    struct check
-    {
-      static_assert(sizeof(int) <= sizeof(T), "not big enough");
-    };
-
-    typedef check<check<bool>> right_angle_brackets;
-
-    int a;
-    decltype(a) b;
-
-    typedef check<int> check_type;
-    check_type c;
-    check_type&& cr = static_cast<check_type&&>(c);],,
-  ax_cv_cxx_compile_cxx0x_native=yes, ax_cv_cxx_compile_cxx0x_native=no)
-  AC_LANG_RESTORE
-  ])
-
-  AC_CACHE_CHECK(if g++ supports C++0x features with -std=c++0x,
-  ax_cv_cxx_compile_cxx0x_cxx,
-  [AC_LANG_SAVE
-  AC_LANG_CPLUSPLUS
-  ac_save_CXXFLAGS="$CXXFLAGS"
-  CXXFLAGS="$CXXFLAGS -std=c++0x"
-  AC_TRY_COMPILE([
-  template <typename T>
-    struct check
-    {
-      static_assert(sizeof(int) <= sizeof(T), "not big enough");
-    };
-
-    typedef check<check<bool>> right_angle_brackets;
-
-    int a;
-    decltype(a) b;
-
-    typedef check<int> check_type;
-    check_type c;
-    check_type&& cr = static_cast<check_type&&>(c);],,
-  ax_cv_cxx_compile_cxx0x_cxx=yes, ax_cv_cxx_compile_cxx0x_cxx=no)
-  CXXFLAGS="$ac_save_CXXFLAGS"
-  AC_LANG_RESTORE
-  ])
-
-  AC_CACHE_CHECK(if g++ supports C++0x features with -std=gnu++0x,
-  ax_cv_cxx_compile_cxx0x_gxx,
-  [AC_LANG_SAVE
-  AC_LANG_CPLUSPLUS
-  ac_save_CXXFLAGS="$CXXFLAGS"
-  CXXFLAGS="$CXXFLAGS -std=gnu++0x"
-  AC_TRY_COMPILE([
-  template <typename T>
-    struct check
-    {
-      static_assert(sizeof(int) <= sizeof(T), "not big enough");
-    };
-
-    typedef check<check<bool>> right_angle_brackets;
-
-    int a;
-    decltype(a) b;
-
-    typedef check<int> check_type;
-    check_type c;
-    check_type&& cr = static_cast<check_type&&>(c);],,
-  ax_cv_cxx_compile_cxx0x_gxx=yes, ax_cv_cxx_compile_cxx0x_gxx=no)
-  CXXFLAGS="$ac_save_CXXFLAGS"
-  AC_LANG_RESTORE
-  ])
-
-  if test "$ax_cv_cxx_compile_cxx0x_native" = yes ||
-     test "$ax_cv_cxx_compile_cxx0x_cxx" = yes ||
-     test "$ax_cv_cxx_compile_cxx0x_gxx" = yes; then
-    AC_DEFINE(HAVE_STDCXX_0X,,[Define if g++ supports C++0x features. ])
-  fi
-
-  if test "$ax_cv_cxx_compile_cxx0x_gxx" = yes; then
-    CXXFLAGS="$CXXFLAGS -std=gnu++0x"
-  elif test "$ax_cv_cxx_compile_cxx0x_cxx" = yes; then
-    CXXFLAGS="$CXXFLAGS -std=c++0x"
-  fi
-])
index 11f7b0db166bd7441bad6ff5a454579deb40ef29..e6ea1d9bdce90b6819ea0875c95bb13ded19f296 100644 (file)
@@ -49,7 +49,6 @@ AC_PROG_INSTALL
 AM_PROG_LEX
 AC_PROG_YACC
 AC_PROG_LIBTOOL
-AX_CXX_COMPILE_STDCXX_0X
 AX_CXX_GCC_ABI_DEMANGLE
 AX_PTHREAD
 AX_BOOST_BASE
index d18795ac81df5a3f80995eb04782e638b8586ff3..f2bfca17ab55e1baf41afc47103a2ef3097fe7bc 100644 (file)
@@ -1578,7 +1578,7 @@ yyreduce:
 /* Line 1806 of yacc.c  */
 #line 120 "config_parser.yy"
     {
-               m_Object = make_shared<ConfigItem>((yyvsp[(4) - (5)].text), (yyvsp[(5) - (5)].text), yylloc);
+               m_Object = boost::make_shared<ConfigItem>((yyvsp[(4) - (5)].text), (yyvsp[(5) - (5)].text), yylloc);
                free((yyvsp[(4) - (5)].text));
                free((yyvsp[(5) - (5)].text));
        }
@@ -1645,7 +1645,7 @@ yyreduce:
 /* Line 1806 of yacc.c  */
 #line 180 "config_parser.yy"
     {
-               m_ExpressionLists.push(make_shared<ExpressionList>());
+               m_ExpressionLists.push(boost::make_shared<ExpressionList>());
        }
     break;
 
@@ -1681,7 +1681,7 @@ yyreduce:
                free((yyvsp[(3) - (6)].text));
                delete (yyvsp[(6) - (6)].variant);
 
-               ExpressionList::Ptr subexprl = make_shared<ExpressionList>();
+               ExpressionList::Ptr subexprl = boost::make_shared<ExpressionList>();
                subexprl->AddExpression(subexpr);
 
                Expression expr((yyvsp[(1) - (6)].text), OperatorPlus, subexprl, yylloc);
@@ -1754,7 +1754,7 @@ yyreduce:
 /* Line 1806 of yacc.c  */
 #line 261 "config_parser.yy"
     {
-               m_Array = make_shared<Dictionary>();
+               m_Array = boost::make_shared<Dictionary>();
        }
     break;
 
index 2ca7aab2547e61383375ffc870abeedab71a7b30..58fd273a87c3b250a5b07893dc42e84ee0b6f3d9 100644 (file)
@@ -118,7 +118,7 @@ object:
        }
 attributes T_OBJECT T_IDENTIFIER T_STRING
        {
-               m_Object = make_shared<ConfigItem>($4, $5, yylloc);
+               m_Object = boost::make_shared<ConfigItem>($4, $5, yylloc);
                free($4);
                free($5);
        }
@@ -178,7 +178,7 @@ inherits_specifier: /* empty */
 
 expressionlist: '{'
        {
-               m_ExpressionLists.push(make_shared<ExpressionList>());
+               m_ExpressionLists.push(boost::make_shared<ExpressionList>());
        }
        expressions
        '}'
@@ -207,7 +207,7 @@ expression: T_IDENTIFIER operator value
                free($3);
                delete $6;
 
-               ExpressionList::Ptr subexprl = make_shared<ExpressionList>();
+               ExpressionList::Ptr subexprl = boost::make_shared<ExpressionList>();
                subexprl->AddExpression(subexpr);
 
                Expression expr($1, OperatorPlus, subexprl, yylloc);
@@ -259,7 +259,7 @@ value: simplevalue
 
 tuple: '('
        {
-               m_Array = make_shared<Dictionary>();
+               m_Array = boost::make_shared<Dictionary>();
        }
        tupleitems
        ')'
index 978f86b17c4e9c6e6b3d5a90baef226bb3cb1fab..08271920b835a6dc437cd0ae516d5bd5d6aef150 100644 (file)
@@ -19,6 +19,8 @@
 
 #include "i2-dyn.h"
 
+using std::ifstream;
+
 using namespace icinga;
 
 ConfigCompiler::ConfigCompiler(istream *input)
@@ -35,7 +37,7 @@ ConfigCompiler::~ConfigCompiler(void)
 size_t ConfigCompiler::ReadInput(char *buffer, size_t max_size)
 {
        m_Input->read(buffer, max_size);
-       return m_Input->gcount();
+       return static_cast<size_t>(m_Input->gcount());
 }
 
 void *ConfigCompiler::GetScanner(void) const
index 43eca579e00f5b51969864aa94350420224e62f4..24dde96c6a778ecc1f0462e07b35dd6a40129c4e 100644 (file)
@@ -79,7 +79,7 @@ ObjectSet<ConfigItem::Ptr>::Ptr ConfigItem::GetAllObjects(void)
        static ObjectSet<ConfigItem::Ptr>::Ptr allObjects;
 
         if (!allObjects) {
-                allObjects = make_shared<ObjectSet<ConfigItem::Ptr> >();
+                allObjects = boost::make_shared<ObjectSet<ConfigItem::Ptr> >();
                 allObjects->Start();
         }
 
@@ -98,7 +98,7 @@ ConfigItem::TNMap::Ptr ConfigItem::GetObjectsByTypeAndName(void)
        static ConfigItem::TNMap::Ptr tnmap;
 
        if (!tnmap) {
-               tnmap = make_shared<ConfigItem::TNMap>(GetAllObjects(), &ConfigItem::GetTypeAndName);
+               tnmap = boost::make_shared<ConfigItem::TNMap>(GetAllObjects(), &ConfigItem::GetTypeAndName);
                tnmap->Start();
        }
 
@@ -109,14 +109,14 @@ void ConfigItem::Commit(void)
 {
        ConfigObject::Ptr dobj = m_ConfigObject.lock();
 
-       Dictionary::Ptr properties = make_shared<Dictionary>();
+       Dictionary::Ptr properties = boost::make_shared<Dictionary>();
        CalculateProperties(properties);
 
        if (!dobj)
                dobj = ConfigObject::GetObject(GetType(), GetName());
 
        if (!dobj)
-               dobj = make_shared<ConfigObject>(properties);
+               dobj = boost::make_shared<ConfigObject>(properties);
        else
                dobj->SetProperties(properties);
 
index 4c7b08ac8a5f9bf7f0283bbe0423201d075e4bf1..64413f1dc0fc0e4fcd6f6c75b5c98a1ac82203ce 100644 (file)
@@ -39,7 +39,7 @@ void Expression::Execute(const Dictionary::Ptr& dictionary) const
        switch (m_Operator) {
                case OperatorSet:
                        if (exprl) {
-                               Dictionary::Ptr dict = make_shared<Dictionary>();
+                               Dictionary::Ptr dict = boost::make_shared<Dictionary>();
                                exprl->Execute(dict);
                                newValue = dict;
                        }
@@ -61,7 +61,7 @@ void Expression::Execute(const Dictionary::Ptr& dictionary) const
                                                throw domain_error(message.str());
                                        }
 
-                                       dict = make_shared<Dictionary>();
+                                       dict = boost::make_shared<Dictionary>();
                                }
 
                                exprl->Execute(dict);
index ce20b737c5880e031357cf755d3d10300c895ea8..3db7e0e93602476e794711ceb0ca2b58e404d0a1 100644 (file)
 #include <stack>
 #include <fstream>
 
+using std::stack;
+using std::istream;
+using std::ostream;
+using std::cin;
+using std::endl;
+
 #ifdef I2_DYN_BUILD
 #      define I2_DYN_API I2_EXPORT
 #else /* I2_DYN_BUILD */
index e114ce79f7ca76aff97b707edf76a45e110da0e7..3f2c4b35ca03ac03d13c696a6992ca1f6db361ab 100644 (file)
@@ -1,6 +1,9 @@
 #include <i2-dyn.h>
 //#include <i2-jsonrpc.h>
 
+using std::cout;
+using std::endl;
+
 using namespace icinga;
 
 int main(int argc, char **argv)
index 96dd96794d286cba96ff793162556126a32b9861..ce482686c3a8dc8d9516a8133b3d393206e8a55e 100644 (file)
@@ -38,6 +38,6 @@ int main(int argc, char **argv)
        LTDL_SET_PRELOADED_SYMBOLS();
 #endif /* _WIN32 */
 
-       IcingaApplication::Ptr instance = make_shared<IcingaApplication>();
+       IcingaApplication::Ptr instance = boost::make_shared<IcingaApplication>();
        return instance->Run(argc, argv);
 }
index 483dd75b5768ce12d7a29d768250184001ff0442..fa310c5422790e1f0e2ee9b44dd8cc094c993070 100644 (file)
@@ -74,9 +74,9 @@ void EndpointManager::AddListener(string service)
 
        stringstream s;
        s << "Adding new listener: port " << service;
-       Application::Log(s.str());
+       Application::Log(LogInformation, "icinga", s.str());
 
-       JsonRpcServer::Ptr server = make_shared<JsonRpcServer>(m_SSLContext);
+       JsonRpcServer::Ptr server = boost::make_shared<JsonRpcServer>(m_SSLContext);
        RegisterServer(server);
 
        server->Bind(service, AF_INET6);
@@ -94,9 +94,9 @@ void EndpointManager::AddConnection(string node, string service)
 {
        stringstream s;
        s << "Adding new endpoint: [" << node << "]:" << service;
-       Application::Log(s.str());
+       Application::Log(LogInformation, "icinga", s.str());
 
-       JsonRpcEndpoint::Ptr endpoint = make_shared<JsonRpcEndpoint>();
+       JsonRpcEndpoint::Ptr endpoint = boost::make_shared<JsonRpcEndpoint>();
        RegisterEndpoint(endpoint);
        endpoint->Connect(node, service, m_SSLContext);
 }
@@ -109,7 +109,7 @@ void EndpointManager::AddConnection(string node, string service)
 void EndpointManager::RegisterServer(JsonRpcServer::Ptr server)
 {
        m_Servers.push_back(server);
-       server->OnNewClient.connect(bind(&EndpointManager::NewClientHandler,
+       server->OnNewClient.connect(boost::bind(&EndpointManager::NewClientHandler,
            this, _1));
 }
 
@@ -118,16 +118,14 @@ void EndpointManager::RegisterServer(JsonRpcServer::Ptr server)
  *
  * @param ncea Event arguments.
  */
-int EndpointManager::NewClientHandler(const NewClientEventArgs& ncea)
+void EndpointManager::NewClientHandler(const NewClientEventArgs& ncea)
 {
        string address = ncea.Client->GetPeerAddress();
-       Application::Log("Accepted new client from " + address);
+       Application::Log(LogInformation, "icinga", "Accepted new client from " + address);
 
-       JsonRpcEndpoint::Ptr endpoint = make_shared<JsonRpcEndpoint>();
+       JsonRpcEndpoint::Ptr endpoint = boost::make_shared<JsonRpcEndpoint>();
        endpoint->SetClient(static_pointer_cast<JsonRpcClient>(ncea.Client));
        RegisterEndpoint(endpoint);
-
-       return 0;
 }
 
 /**
@@ -259,7 +257,7 @@ void EndpointManager::SendMulticastMessage(Endpoint::Ptr sender,
  *
  * @param callback The callback function.
  */
-void EndpointManager::ForEachEndpoint(function<int (const NewEndpointEventArgs&)> callback)
+void EndpointManager::ForEachEndpoint(function<void (const NewEndpointEventArgs&)> callback)
 {
        NewEndpointEventArgs neea;
        neea.Source = shared_from_this();
@@ -292,7 +290,7 @@ Endpoint::Ptr EndpointManager::GetEndpointByIdentity(string identity) const
 
 void EndpointManager::SendAPIMessage(Endpoint::Ptr sender,
     RequestMessage& message,
-    function<int(const NewResponseEventArgs&)> callback, time_t timeout)
+    function<void(const NewResponseEventArgs&)> callback, time_t timeout)
 {
        m_NextMessageID++;
 
@@ -326,8 +324,8 @@ void EndpointManager::RescheduleRequestTimer(void)
            &EndpointManager::RequestTimeoutLessComparer);
 
        if (!m_RequestTimer) {
-               m_RequestTimer = make_shared<Timer>();
-               m_RequestTimer->OnTimerExpired.connect(bind(&EndpointManager::RequestTimerHandler, this, _1));
+               m_RequestTimer = boost::make_shared<Timer>();
+               m_RequestTimer->OnTimerExpired.connect(boost::bind(&EndpointManager::RequestTimerHandler, this));
        }
 
        if (it != m_Requests.end()) {
@@ -342,7 +340,7 @@ void EndpointManager::RescheduleRequestTimer(void)
        }
 }
 
-int EndpointManager::RequestTimerHandler(const TimerEventArgs& ea)
+void EndpointManager::RequestTimerHandler(void)
 {
        map<string, PendingRequest>::iterator it;
        for (it = m_Requests.begin(); it != m_Requests.end(); it++) {
@@ -361,8 +359,6 @@ int EndpointManager::RequestTimerHandler(const TimerEventArgs& ea)
        }
 
        RescheduleRequestTimer();
-
-       return 0;
 }
 
 void EndpointManager::ProcessResponseMessage(const Endpoint::Ptr& sender, const ResponseMessage& message)
index 3a9ac354c8a911143bcd8e3a3106236833ece909..8636f1e8b14b1797688abf6089252bf699b8ae96 100644 (file)
@@ -44,7 +44,7 @@ struct I2_ICINGA_API PendingRequest
 {
        time_t Timeout;
        RequestMessage Request;
-       function<int(const NewResponseEventArgs&)> Callback;
+       function<void(const NewResponseEventArgs&)> Callback;
 
        bool HasTimedOut(void) const
        {
@@ -97,11 +97,11 @@ public:
        void SendMulticastMessage(Endpoint::Ptr sender, const RequestMessage& message);
 
        void SendAPIMessage(Endpoint::Ptr sender, RequestMessage& message,
-           function<int(const NewResponseEventArgs&)> callback, time_t timeout = 10);
+           function<void(const NewResponseEventArgs&)> callback, time_t timeout = 10);
 
        void ProcessResponseMessage(const Endpoint::Ptr& sender, const ResponseMessage& message);
 
-       void ForEachEndpoint(function<int (const NewEndpointEventArgs&)> callback);
+       void ForEachEndpoint(function<void (const NewEndpointEventArgs&)> callback);
 
        Endpoint::Ptr GetEndpointByIdentity(string identity) const;
 
@@ -123,9 +123,9 @@ private:
 
        static bool RequestTimeoutLessComparer(const pair<string, PendingRequest>& a, const pair<string, PendingRequest>& b);
        void RescheduleRequestTimer(void);
-       int RequestTimerHandler(const TimerEventArgs& ea);
+       void RequestTimerHandler(void);
 
-       int NewClientHandler(const NewClientEventArgs& ncea);
+       void NewClientHandler(const NewClientEventArgs& ncea);
 };
 
 }
index 18d3f36768eec24ec5faa3e987acd2a9ccc0aa12..4780298e720c90090bf92d40ffd0da613b24dc36 100644 (file)
@@ -37,31 +37,33 @@ using namespace icinga;
 int IcingaApplication::Main(const vector<string>& args)
 {
 #ifdef _WIN32
-       Application::Log("Icinga component loader");
+       Application::Log(LogInformation, "icinga", "Icinga component loader");
 #else /* _WIN32 */
-       Application::Log("Icinga component loader (version: " ICINGA_VERSION ")");
+       Application::Log(LogInformation, "icinga", "Icinga component loader (version: " ICINGA_VERSION ")");
 #endif  /* _WIN32 */
 
        if (args.size() < 2) {
-               cout << "Syntax: " << args[0] << " <config-file>" << endl;
+               stringstream msgbuf;
+               msgbuf << "Syntax: " << args[0] << " <config-file>";
+               Application::Log(LogInformation, "icinga", msgbuf.str());
                return EXIT_FAILURE;
        }
 
-       m_EndpointManager = make_shared<EndpointManager>();
+       m_EndpointManager = boost::make_shared<EndpointManager>();
 
        string componentDirectory = GetExeDirectory() + "/../lib/icinga2";
        AddComponentSearchDir(componentDirectory);
 
        /* register handler for 'component' config objects */
-       static ConfigObject::Set::Ptr componentObjects = make_shared<ConfigObject::Set>(ConfigObject::GetAllObjects(), ConfigObject::MakeTypePredicate("component"));
-       function<int (const ObjectSetEventArgs<ConfigObject::Ptr>&)> NewComponentHandler = bind(&IcingaApplication::NewComponentHandler, this, _1);
+       static ConfigObject::Set::Ptr componentObjects = boost::make_shared<ConfigObject::Set>(ConfigObject::GetAllObjects(), ConfigObject::MakeTypePredicate("component"));
+       function<void (const ObjectSetEventArgs<ConfigObject::Ptr>&)> NewComponentHandler = boost::bind(&IcingaApplication::NewComponentHandler, this, _1);
        componentObjects->OnObjectAdded.connect(NewComponentHandler);
        componentObjects->OnObjectCommitted.connect(NewComponentHandler);
-       componentObjects->OnObjectRemoved.connect(bind(&IcingaApplication::DeletedComponentHandler, this, _1));
+       componentObjects->OnObjectRemoved.connect(boost::bind(&IcingaApplication::DeletedComponentHandler, this, _1));
        componentObjects->Start();
 
        /* load config file */
-       ConfigObject::Ptr fileComponentConfig = make_shared<ConfigObject>("component", "configfile");
+       ConfigObject::Ptr fileComponentConfig = boost::make_shared<ConfigObject>("component", "configfile");
        fileComponentConfig->SetLocal(true);
        fileComponentConfig->SetProperty("configFilename", args[1]);
        fileComponentConfig->Commit();
@@ -84,7 +86,7 @@ int IcingaApplication::Main(const vector<string>& args)
                /* set up SSL context */
                shared_ptr<X509> cert = Utility::GetX509Certificate(GetPublicKeyFile());
                string identity = Utility::GetCertificateCN(cert);
-               Application::Log("My identity: " + identity);
+               Application::Log(LogInformation, "icinga", "My identity: " + identity);
                m_EndpointManager->SetIdentity(identity);
 
                shared_ptr<SSL_CTX> sslContext = Utility::MakeSSLContext(GetPublicKeyFile(), GetPrivateKeyFile(), GetCAKeyFile());
@@ -111,7 +113,7 @@ EndpointManager::Ptr IcingaApplication::GetEndpointManager(void)
        return m_EndpointManager;
 }
 
-int IcingaApplication::NewComponentHandler(const ObjectSetEventArgs<ConfigObject::Ptr>& ea)
+void IcingaApplication::NewComponentHandler(const ObjectSetEventArgs<ConfigObject::Ptr>& ea)
 {
        ConfigObject::Ptr object = ea.Target;
        
@@ -129,18 +131,14 @@ int IcingaApplication::NewComponentHandler(const ObjectSetEventArgs<ConfigObject
        }
 
        LoadComponent(path, object);
-
-       return 0;
 }
 
-int IcingaApplication::DeletedComponentHandler(const ObjectSetEventArgs<ConfigObject::Ptr>& ea)
+void IcingaApplication::DeletedComponentHandler(const ObjectSetEventArgs<ConfigObject::Ptr>& ea)
 {
        ConfigObject::Ptr object = ea.Target;
 
        Component::Ptr component = GetComponent(object->GetName());
        UnregisterComponent(component);
-
-       return 0;
 }
 
 string IcingaApplication::GetPrivateKeyFile(void) const
index de6b82b0ee01de5b1d1b54ba3f67c93d96be1e95..6b928d129b26c26f47c0af4eab44a713883d6847 100644 (file)
@@ -53,14 +53,8 @@ private:
        string m_Node;
        string m_Service;
 
-       int NewComponentHandler(const ObjectSetEventArgs<ConfigObject::Ptr>& ea);
-       int DeletedComponentHandler(const ObjectSetEventArgs<ConfigObject::Ptr>& ea);
-
-       int NewRpcListenerHandler(const EventArgs& ea);
-       int DeletedRpcListenerHandler(const EventArgs& ea);
-
-       int NewRpcConnectionHandler(const EventArgs& ea);
-       int DeletedRpcConnectionHandler(const EventArgs& ea);
+       void NewComponentHandler(const ObjectSetEventArgs<ConfigObject::Ptr>& ea);
+       void DeletedComponentHandler(const ObjectSetEventArgs<ConfigObject::Ptr>& ea);
 };
 
 }
index 02442ccf9d319c65a4d0647ccd67a49931467a0b..594141c6a402ddfa1a7277a41ae9c44db3535b40 100644 (file)
@@ -36,7 +36,7 @@ JsonRpcClient::Ptr JsonRpcEndpoint::GetClient(void)
 
 void JsonRpcEndpoint::Connect(string node, string service, shared_ptr<SSL_CTX> sslContext)
 {
-       JsonRpcClient::Ptr client = make_shared<JsonRpcClient>(RoleOutbound, sslContext);
+       JsonRpcClient::Ptr client = boost::make_shared<JsonRpcClient>(RoleOutbound, sslContext);
        SetClient(client);
        client->Connect(node, service);
        client->Start();
@@ -45,10 +45,10 @@ void JsonRpcEndpoint::Connect(string node, string service, shared_ptr<SSL_CTX> s
 void JsonRpcEndpoint::SetClient(JsonRpcClient::Ptr client)
 {
        m_Client = client;
-       client->OnNewMessage.connect(bind(&JsonRpcEndpoint::NewMessageHandler, this, _1));
-       client->OnClosed.connect(bind(&JsonRpcEndpoint::ClientClosedHandler, this, _1));
-       client->OnError.connect(bind(&JsonRpcEndpoint::ClientErrorHandler, this, _1));
-       client->OnVerifyCertificate.connect(bind(&JsonRpcEndpoint::VerifyCertificateHandler, this, _1));
+       client->OnNewMessage.connect(boost::bind(&JsonRpcEndpoint::NewMessageHandler, this, _1));
+       client->OnClosed.connect(boost::bind(&JsonRpcEndpoint::ClientClosedHandler, this, _1));
+       client->OnError.connect(boost::bind(&JsonRpcEndpoint::ClientErrorHandler, this, _1));
+       client->OnVerifyCertificate.connect(boost::bind(&JsonRpcEndpoint::VerifyCertificateHandler, this, _1));
 }
 
 bool JsonRpcEndpoint::IsLocal(void) const
@@ -80,7 +80,7 @@ void JsonRpcEndpoint::ProcessResponse(Endpoint::Ptr sender, const ResponseMessag
        m_Client->SendMessage(message);
 }
 
-int JsonRpcEndpoint::NewMessageHandler(const NewMessageEventArgs& nmea)
+void JsonRpcEndpoint::NewMessageHandler(const NewMessageEventArgs& nmea)
 {
        const MessagePart& message = nmea.Message;
        Endpoint::Ptr sender = static_pointer_cast<Endpoint>(shared_from_this());
@@ -89,15 +89,15 @@ int JsonRpcEndpoint::NewMessageHandler(const NewMessageEventArgs& nmea)
                /* rather than routing the message to the right virtual
                 * endpoint we just process it here right away. */
                GetEndpointManager()->ProcessResponseMessage(sender, message);
-               return 0;
+               return;
        }
 
        string method;
        if (!message.GetProperty("method", &method))
-               return 0;
+               return;
 
        if (!HasPublication(method))
-               return 0;
+               return;
 
        RequestMessage request = message;
 
@@ -106,13 +106,11 @@ int JsonRpcEndpoint::NewMessageHandler(const NewMessageEventArgs& nmea)
                GetEndpointManager()->SendAnycastMessage(sender, request);
        else
                GetEndpointManager()->SendMulticastMessage(sender, request);
-
-       return 0;
 }
 
-int JsonRpcEndpoint::ClientClosedHandler(const EventArgs&)
+void JsonRpcEndpoint::ClientClosedHandler(const EventArgs&)
 {
-       Application::Log("Lost connection to endpoint: identity=" + GetIdentity());
+       Application::Log(LogWarning, "jsonrpc", "Lost connection to endpoint: identity=" + GetIdentity());
 
        m_PendingCalls.clear();
 
@@ -130,18 +128,17 @@ int JsonRpcEndpoint::ClientClosedHandler(const EventArgs&)
        m_Client.reset();
 
        // TODO: persist events, etc., for now we just disable the endpoint
-
-       return 0;
 }
 
-int JsonRpcEndpoint::ClientErrorHandler(const SocketErrorEventArgs& ea)
+void JsonRpcEndpoint::ClientErrorHandler(const SocketErrorEventArgs& ea)
 {
-       cerr << "Error occured for JSON-RPC socket: Message=" << ea.Exception.what() << endl;
+       stringstream message;
+       message << "Error occured for JSON-RPC socket: Message=" << ea.Exception.what();
 
-       return 0;
+       Application::Log(LogWarning, "jsonrpc", message.str());
 }
 
-int JsonRpcEndpoint::VerifyCertificateHandler(const VerifyCertificateEventArgs& ea)
+void JsonRpcEndpoint::VerifyCertificateHandler(const VerifyCertificateEventArgs& ea)
 {
        if (ea.Certificate && ea.ValidCertificate) {
                string identity = Utility::GetCertificateCN(ea.Certificate);
@@ -149,8 +146,6 @@ int JsonRpcEndpoint::VerifyCertificateHandler(const VerifyCertificateEventArgs&
                if (GetIdentity().empty() && !identity.empty())
                        SetIdentity(identity);
        }
-
-       return 0;
 }
 
 void JsonRpcEndpoint::Stop(void)
index 7601e1eb9a22a0104c6242dab57b6d266cbe0aa1..2c07eb54e37eb6e93570f30ae23075a84c29b68a 100644 (file)
@@ -58,10 +58,10 @@ private:
        JsonRpcClient::Ptr m_Client;
        map<string, Endpoint::Ptr> m_PendingCalls;
 
-       int NewMessageHandler(const NewMessageEventArgs& nmea);
-       int ClientClosedHandler(const EventArgs& ea);
-       int ClientErrorHandler(const SocketErrorEventArgs& ea);
-       int VerifyCertificateHandler(const VerifyCertificateEventArgs& ea);
+       void NewMessageHandler(const NewMessageEventArgs& nmea);
+       void ClientClosedHandler(const EventArgs& ea);
+       void ClientErrorHandler(const SocketErrorEventArgs& ea);
+       void VerifyCertificateHandler(const VerifyCertificateEventArgs& ea);
 };
 
 }
index f6adac5b125593e60f28d08d24bf765318a429c1..26868806bf46169584b9969fadf08054d2be4086 100644 (file)
@@ -17,7 +17,7 @@ CheckResult NagiosCheckTask::Execute(void) const
 
        string command = m_Command + " 2>&1";
 
-       Application::Log("Nagios check command: " + command);
+       Application::Log(LogDebug, "icinga", "Nagios check command: " + command);
 
 #ifdef _MSC_VER
        fp = _popen(command.c_str(), "r");
@@ -39,7 +39,7 @@ CheckResult NagiosCheckTask::Execute(void) const
 
        cr.Output = output.str();
 
-       Application::Log("Nagios plugin output: " + cr.Output);
+       Application::Log(LogDebug, "icinga", "Nagios plugin output: " + cr.Output);
 
        int status, exitcode;
 #ifdef _MSC_VER
@@ -85,5 +85,5 @@ CheckTask::Ptr NagiosCheckTask::CreateTask(const Service& service)
 {
        assert(service.GetCheckType() == "nagios");
 
-       return make_shared<NagiosCheckTask>(service);
+       return boost::make_shared<NagiosCheckTask>(service);
 }
index ca4951eec1ac0045692ed48ba2eed6afe61fc623..8737d9ff3862c10cb7d83fe2406f8e4f5af58c67 100644 (file)
@@ -38,7 +38,7 @@ bool VirtualEndpoint::IsConnected(void) const
        return true;
 }
 
-void VirtualEndpoint::RegisterTopicHandler(string topic, function<int (const NewRequestEventArgs&)> callback)
+void VirtualEndpoint::RegisterTopicHandler(string topic, function<void (const NewRequestEventArgs&)> callback)
 {
        map<string, shared_ptr<boost::signal<void (const NewRequestEventArgs&)> > >::iterator it;
        it = m_TopicHandlers.find(topic);
@@ -46,7 +46,7 @@ void VirtualEndpoint::RegisterTopicHandler(string topic, function<int (const New
        shared_ptr<boost::signal<void (const NewRequestEventArgs&)> > sig;
 
        if (it == m_TopicHandlers.end()) {
-               sig = make_shared<boost::signal<void (const NewRequestEventArgs&)> >();
+               sig = boost::make_shared<boost::signal<void (const NewRequestEventArgs&)> >();
                m_TopicHandlers.insert(make_pair(topic, sig));
        } else {
                sig = it->second;
@@ -57,7 +57,7 @@ void VirtualEndpoint::RegisterTopicHandler(string topic, function<int (const New
        RegisterSubscription(topic);
 }
 
-void VirtualEndpoint::UnregisterTopicHandler(string topic, function<int (const NewRequestEventArgs&)> callback)
+void VirtualEndpoint::UnregisterTopicHandler(string topic, function<void (const NewRequestEventArgs&)> callback)
 {
        // TODO: implement
        //m_TopicHandlers[method] -= callback;
index 19f1ecfa26dc87219fb0712335977416b4268f62..9e42f34a92c38766762d844ea2c2d573a647d42e 100644 (file)
@@ -45,8 +45,8 @@ public:
        typedef shared_ptr<VirtualEndpoint> Ptr;
        typedef weak_ptr<VirtualEndpoint> WeakPtr;
 
-       void RegisterTopicHandler(string topic, function<int (const NewRequestEventArgs&)> callback);
-       void UnregisterTopicHandler(string topic, function<int (const NewRequestEventArgs&)> callback);
+       void RegisterTopicHandler(string topic, function<void (const NewRequestEventArgs&)> callback);
+       void UnregisterTopicHandler(string topic, function<void (const NewRequestEventArgs&)> callback);
 
        virtual string GetAddress(void) const;
 
index 5cfa7674933d7da30de7007f33f8a912d3700adc..e7ce12ce2afff69fef5c4aa95d5502be0964f2ba 100644 (file)
@@ -34,7 +34,7 @@ void JsonRpcClient::Start(void)
 {
        TlsClient::Start();
 
-       OnDataAvailable.connect(bind(&JsonRpcClient::DataAvailableHandler, this, _1));
+       OnDataAvailable.connect(boost::bind(&JsonRpcClient::DataAvailableHandler, this, _1));
 }
 
 /**
@@ -53,7 +53,7 @@ void JsonRpcClient::SendMessage(const MessagePart& message)
  * @param - Event arguments for the event.
  * @returns 0
  */
-int JsonRpcClient::DataAvailableHandler(const EventArgs&)
+void JsonRpcClient::DataAvailableHandler(const EventArgs&)
 {
        for (;;) {
                try {
@@ -61,7 +61,7 @@ int JsonRpcClient::DataAvailableHandler(const EventArgs&)
                        MessagePart message;
 
                        if (!Netstring::ReadStringFromFIFO(GetRecvQueue(), &jsonString))
-                               break;
+                               return;
 
                        message = MessagePart(jsonString);
 
@@ -70,14 +70,12 @@ int JsonRpcClient::DataAvailableHandler(const EventArgs&)
                        nea.Message = message;
                        OnNewMessage(nea);
                } catch (const Exception& ex) {
-                       Application::Log("Exception while processing message from JSON-RPC client: " + string(ex.GetMessage()));
+                       Application::Log(LogCritical, "jsonrpc", "Exception while processing message from JSON-RPC client: " + string(ex.GetMessage()));
                        Close();
 
-                       return 0;
+                       return;
                }
        }
-
-       return 0;
 }
 
 /**
@@ -89,5 +87,5 @@ int JsonRpcClient::DataAvailableHandler(const EventArgs&)
  */
 JsonRpcClient::Ptr icinga::JsonRpcClientFactory(TcpClientRole role, shared_ptr<SSL_CTX> sslContext)
 {
-       return make_shared<JsonRpcClient>(role, sslContext);
+       return boost::make_shared<JsonRpcClient>(role, sslContext);
 }
index 463481aa56095dc3ea7edff0b0ee01fb62938310..384dff3c426a3eb6b1925614b4d1d229cf01a3e6 100644 (file)
@@ -53,7 +53,7 @@ public:
        boost::signal<void (const NewMessageEventArgs&)> OnNewMessage;
 
 private:
-       int DataAvailableHandler(const EventArgs&);
+       void DataAvailableHandler(const EventArgs&);
 };
 
 JsonRpcClient::Ptr JsonRpcClientFactory(TcpClientRole role, shared_ptr<SSL_CTX> sslContext);
index 77bb9e4749a4f44b6e2d2b6c50327643ca1e1458..a39d2c594a47b641c649b67b5d6d6282326ba3cc 100644 (file)
@@ -28,5 +28,5 @@ using namespace icinga;
  */
 JsonRpcServer::JsonRpcServer(shared_ptr<SSL_CTX> sslContext)
 {
-       SetClientFactory(bind(&JsonRpcClientFactory, RoleInbound, sslContext));
+       SetClientFactory(boost::bind(&JsonRpcClientFactory, RoleInbound, sslContext));
 }
index ee405c08123b923cbca5038b64bce093c3069189..0f1cf1f11c0d8cf061c54e3209722fa59fc95c09 100644 (file)
@@ -27,7 +27,7 @@ using namespace icinga;
  */
 MessagePart::MessagePart(void)
 {
-       m_Dictionary = make_shared<Dictionary>();
+       m_Dictionary = boost::make_shared<Dictionary>();
 }
 
 /**
@@ -76,7 +76,7 @@ MessagePart::MessagePart(const MessagePart& message)
  */
 Dictionary::Ptr MessagePart::GetDictionaryFromJson(json_t *json)
 {
-       Dictionary::Ptr dictionary = make_shared<Dictionary>();
+       Dictionary::Ptr dictionary = boost::make_shared<Dictionary>();
 
        for (cJSON *i = json->child; i != NULL; i = i->next) {
                switch (i->type) {