From 0bd53236299737f4baf665b5e8e27a58bc1eed43 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Fri, 15 Jun 2012 19:32:41 +0200 Subject: [PATCH] Prefer boost::* over C++0x features. --- base/Makefile.am | 3 - base/application.cpp | 41 +++++-- base/application.h | 10 +- base/base.vcxproj | 4 +- base/configobject.cpp | 12 +- base/cxx11-compat.h | 45 ------- base/exception.cpp | 3 + base/fifo.cpp | 2 + base/i2-base.h | 57 +++++---- base/objectmap.h | 20 ++-- base/objectset.h | 20 ++-- base/socket.cpp | 14 +-- base/socket.h | 2 +- base/tcpclient.cpp | 26 ++-- base/tcpclient.h | 4 +- base/tcpserver.cpp | 4 +- base/tcpsocket.cpp | 2 +- base/timer.cpp | 27 +---- base/timer.h | 22 +--- base/tlsclient.cpp | 28 ++--- base/tlsclient.h | 4 +- components/checker/checkercomponent.cpp | 102 +++++++++++----- components/checker/checkercomponent.h | 14 ++- components/checker/i2-checker.h | 2 + components/configfile/configfilecomponent.cpp | 8 +- components/configrpc/configrpccomponent.cpp | 68 +++++------ components/configrpc/configrpccomponent.h | 14 +-- components/delegation/delegationcomponent.cpp | 46 +++---- components/delegation/delegationcomponent.h | 12 +- components/demo/democomponent.cpp | 21 ++-- components/demo/democomponent.h | 4 +- components/discovery/discoverycomponent.cpp | 79 +++++------- components/discovery/discoverycomponent.h | 16 +-- config/ax_cxx_compile_stdcxx_0x.m4 | 113 ------------------ configure.ac | 1 - dyn/config_parser.cc | 8 +- dyn/config_parser.yy | 8 +- dyn/configcompiler.cpp | 4 +- dyn/configitem.cpp | 8 +- dyn/expression.cpp | 4 +- dyn/i2-dyn.h | 6 + dyntest/dyntest.cpp | 3 + icinga-app/icinga.cpp | 2 +- icinga/endpointmanager.cpp | 30 ++--- icinga/endpointmanager.h | 10 +- icinga/icingaapplication.cpp | 28 ++--- icinga/icingaapplication.h | 10 +- icinga/jsonrpcendpoint.cpp | 37 +++--- icinga/jsonrpcendpoint.h | 8 +- icinga/nagioschecktask.cpp | 6 +- icinga/virtualendpoint.cpp | 6 +- icinga/virtualendpoint.h | 4 +- jsonrpc/jsonrpcclient.cpp | 14 +-- jsonrpc/jsonrpcclient.h | 2 +- jsonrpc/jsonrpcserver.cpp | 2 +- jsonrpc/messagepart.cpp | 4 +- 56 files changed, 426 insertions(+), 628 deletions(-) delete mode 100644 base/cxx11-compat.h delete mode 100644 config/ax_cxx_compile_stdcxx_0x.m4 diff --git a/base/Makefile.am b/base/Makefile.am index f95a39758..f1aab07a1 100644 --- a/base/Makefile.am +++ b/base/Makefile.am @@ -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 \ diff --git a/base/application.cpp b/base/application.cpp index a277104d8..4f7f95c38 100644 --- a/base/application.cpp +++ b/base/application.cpp @@ -23,6 +23,9 @@ # include #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::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; } diff --git a/base/application.h b/base/application.h index 958608d24..56383b049 100644 --- a/base/application.h +++ b/base/application.h @@ -22,6 +22,14 @@ 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 LoadComponent(const string& path, const ConfigObject::Ptr& componentConfig); diff --git a/base/base.vcxproj b/base/base.vcxproj index f7e4cc647..fd5a13cf4 100644 --- a/base/base.vcxproj +++ b/base/base.vcxproj @@ -35,12 +35,10 @@ - - + - diff --git a/base/configobject.cpp b/base/configobject.cpp index fd5efcf7d..da273b447 100644 --- a/base/configobject.cpp +++ b/base/configobject.cpp @@ -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()) + m_Properties(properties), m_Tags(boost::make_shared()) { } ConfigObject::ConfigObject(string type, string name, const ConfigObject::Set::Ptr& container) : m_Container(container ? container : GetAllObjects()), - m_Properties(make_shared()), m_Tags(make_shared()) + m_Properties(boost::make_shared()), m_Tags(boost::make_shared()) { SetProperty("__type", type); SetProperty("__name", name); @@ -106,7 +106,7 @@ ObjectSet::Ptr ConfigObject::GetAllObjects(void) static ObjectSet::Ptr allObjects; if (!allObjects) { - allObjects = make_shared >(); + allObjects = boost::make_shared >(); allObjects->Start(); } @@ -118,7 +118,7 @@ ConfigObject::TNMap::Ptr ConfigObject::GetObjectsByTypeAndName(void) static ConfigObject::TNMap::Ptr tnmap; if (!tnmap) { - tnmap = make_shared(GetAllObjects(), &ConfigObject::TypeAndNameGetter); + tnmap = boost::make_shared(GetAllObjects(), &ConfigObject::TypeAndNameGetter); tnmap->Start(); } @@ -147,7 +147,7 @@ bool ConfigObject::TypeAndNameGetter(const ConfigObject::Ptr& object, pair 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::Ptr tmap; if (!tmap) { - tmap = make_shared(GetAllObjects(), &ConfigObject::TypeGetter); + tmap = boost::make_shared(GetAllObjects(), &ConfigObject::TypeGetter); tmap->Start(); } diff --git a/base/cxx11-compat.h b/base/cxx11-compat.h deleted file mode 100644 index 684f6b50d..000000000 --- a/base/cxx11-compat.h +++ /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 -shared_ptr make_shared(void) -{ - return shared_ptr(new T()); -} - -template -shared_ptr make_shared(const TArg1& arg1) -{ - return shared_ptr(new T(arg1)); -} - -template -shared_ptr make_shared(const TArg1& arg1, const TArg2& arg2) -{ - return shared_ptr(new T(arg1, arg2)); -} - -} - -#endif /* CXX11COMPAT_H */ diff --git a/base/exception.cpp b/base/exception.cpp index f0b609634..fbb796369 100644 --- a/base/exception.cpp +++ b/base/exception.cpp @@ -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; diff --git a/base/fifo.cpp b/base/fifo.cpp index bb83e7c87..1a5caa65a 100644 --- a/base/fifo.cpp +++ b/base/fifo.cpp @@ -19,6 +19,8 @@ #include "i2-base.h" +using std::bad_alloc; + using namespace icinga; /** diff --git a/base/i2-base.h b/base/i2-base.h index 4dcc25e3e..c5182727d 100644 --- a/base/i2-base.h +++ b/base/i2-base.h @@ -53,7 +53,6 @@ */ #ifdef _MSC_VER -# define HAVE_STDCXX_0X # pragma warning(disable:4251) # pragma warning(disable:4275) # define _CRT_SECURE_NO_DEPRECATE @@ -93,35 +92,35 @@ #include #include -using namespace std; - -#ifdef HAVE_STDCXX_0X -# include -# include - -using namespace std::placeholders; - -#else /* HAVE_STDCXX_0X */ -# ifdef HAVE_BOOST -# include -# include -# include -# include - -using namespace boost; - -# else /* HAVE_BOOST */ -# include -# include -# 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 +#include +#include +#include #include +#include + +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" diff --git a/base/objectmap.h b/base/objectmap.h index 9b975412f..0fb42f55d 100644 --- a/base/objectmap.h +++ b/base/objectmap.h @@ -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::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&)> callback) + void ForeachObject(TKey key, function&)> callback) { ObjectSetEventArgs ea; ea.Source = shared_from_this(); @@ -105,25 +105,19 @@ private: AddObject(object); } - int ObjectAddedHandler(const ObjectSetEventArgs& ea) + void ObjectAddedHandler(const ObjectSetEventArgs& ea) { AddObject(ea.Target); - - return 0; } - int ObjectCommittedHandler(const ObjectSetEventArgs& ea) + void ObjectCommittedHandler(const ObjectSetEventArgs& ea) { CheckObject(ea.Target); - - return 0; } - int ObjectRemovedHandler(const ObjectSetEventArgs& ea) + void ObjectRemovedHandler(const ObjectSetEventArgs& ea) { RemoveObject(ea.Target); - - return 0; } }; diff --git a/base/objectset.h b/base/objectset.h index ad4d41c98..692723e8c 100644 --- a/base/objectset.h +++ b/base/objectset.h @@ -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&)> callback) + void ForeachObject(function&)> callback) { ObjectSetEventArgs ea; ea.Source = shared_from_this(); @@ -138,18 +136,14 @@ private: typename ObjectSet::Ptr m_Parent; function m_Predicate; - int ObjectAddedOrCommittedHandler(const ObjectSetEventArgs& ea) + void ObjectAddedOrCommittedHandler(const ObjectSetEventArgs& ea) { CheckObject(ea.Target); - - return 0; } - int ObjectRemovedHandler(const ObjectSetEventArgs& ea) + void ObjectRemovedHandler(const ObjectSetEventArgs& ea) { RemoveObject(ea.Target); - - return 0; } }; diff --git a/base/socket.cpp b/base/socket.cpp index 6cee85988..570c0363e 100644 --- a/base/socket.cpp +++ b/base/socket.cpp @@ -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(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; } /** diff --git a/base/socket.h b/base/socket.h index 9d111d4a4..feb8a2c58 100644 --- a/base/socket.h +++ b/base/socket.h @@ -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); }; diff --git a/base/tcpclient.cpp b/base/tcpclient.cpp index 655253771..4b5e07113 100644 --- a/base/tcpclient.cpp +++ b/base/tcpclient.cpp @@ -30,8 +30,8 @@ TcpClient::TcpClient(TcpClientRole role) { m_Role = role; - m_SendQueue = make_shared(); - m_RecvQueue = make_shared(); + m_SendQueue = boost::make_shared(); + m_RecvQueue = boost::make_shared(); } /** @@ -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(role); + return boost::make_shared(role); } diff --git a/base/tcpclient.h b/base/tcpclient.h index 997c0ce05..5f2d553cb 100644 --- a/base/tcpclient.h +++ b/base/tcpclient.h @@ -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); }; /** diff --git a/base/tcpserver.cpp b/base/tcpserver.cpp index f790775dc..e50343ff4 100644 --- a/base/tcpserver.cpp +++ b/base/tcpserver.cpp @@ -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)); } /** diff --git a/base/tcpsocket.cpp b/base/tcpsocket.cpp index d2932e9a6..201328e7e 100644 --- a/base/tcpsocket.cpp +++ b/base/tcpsocket.cpp @@ -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) { diff --git a/base/timer.cpp b/base/timer.cpp index 592c068b6..bf212786e 100644 --- a/base/timer.cpp +++ b/base/timer.cpp @@ -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. */ diff --git a/base/timer.h b/base/timer.h index 9bf8bfa4e..5f119e11a 100644 --- a/base/timer.h +++ b/base/timer.h @@ -24,16 +24,6 @@ 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 OnTimerExpired; + boost::signal 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). */ diff --git a/base/tlsclient.cpp b/base/tlsclient.cpp index 2669b4d26..886b5ea6c 100644 --- a/base/tlsclient.cpp +++ b/base/tlsclient.cpp @@ -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 sslContext) { - return make_shared(role, sslContext); + return boost::make_shared(role, sslContext); } /** diff --git a/base/tlsclient.h b/base/tlsclient.h index 2bc33e727..2773c0c96 100644 --- a/base/tlsclient.h +++ b/base/tlsclient.h @@ -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); diff --git a/components/checker/checkercomponent.cpp b/components/checker/checkercomponent.cpp index 504280c62..79ef54ae8 100644 --- a/components/checker/checkercomponent.cpp +++ b/components/checker/checkercomponent.cpp @@ -28,17 +28,19 @@ string CheckerComponent::GetName(void) const void CheckerComponent::Start(void) { - m_CheckerEndpoint = make_shared(); + m_CheckerEndpoint = boost::make_shared(); 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(); + m_CheckTimer = boost::make_shared(); 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(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(¶ms)) - return 0; + return; MessagePart serviceMsg; if (!params.GetProperty("service", &serviceMsg)) - return 0; + return; - ConfigObject::Ptr object = make_shared(serviceMsg.GetDictionary()); + ConfigObject::Ptr object = boost::make_shared(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(¶ms)) + return; + + string name; + if (!params.GetProperty("service", &name)) + return; + + vector 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::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); diff --git a/components/checker/checkercomponent.h b/components/checker/checkercomponent.h index 4198ad173..7dca5ccce 100644 --- a/components/checker/checkercomponent.h +++ b/components/checker/checkercomponent.h @@ -38,19 +38,25 @@ public: class CheckerComponent : public IcingaComponent { public: + typedef shared_ptr Ptr; + typedef weak_ptr WeakPtr; + + typedef priority_queue, ServiceNextCheckLessComparer> ServiceQueue; + virtual string GetName(void) const; virtual void Start(void); virtual void Stop(void); private: - priority_queue, 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); }; } diff --git a/components/checker/i2-checker.h b/components/checker/i2-checker.h index fc804edde..8a0ad53de 100644 --- a/components/checker/i2-checker.h +++ b/components/checker/i2-checker.h @@ -31,6 +31,8 @@ #include +using std::priority_queue; + #include "checkercomponent.h" #endif /* I2CHECKER_H */ diff --git a/components/configfile/configfilecomponent.cpp b/components/configfile/configfilecomponent.cpp index c7f04a2c8..ac6e92a57 100644 --- a/components/configfile/configfilecomponent.cpp +++ b/components/configfile/configfilecomponent.cpp @@ -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::Ptr fifo = boost::make_shared(); 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 configItems = ConfigCompiler::CompileFile(filename); - Application::Log("Executing config items..."); + Application::Log(LogInformation, "configfile", "Executing config items..."); ConfigVM::ExecuteItems(configItems); } diff --git a/components/configrpc/configrpccomponent.cpp b/components/configrpc/configrpccomponent.cpp index b9fbf8f2f..38ae78d31 100644 --- a/components/configrpc/configrpccomponent.cpp +++ b/components/configrpc/configrpccomponent.cpp @@ -30,28 +30,28 @@ void ConfigRpcComponent::Start(void) { EndpointManager::Ptr endpointManager = GetEndpointManager(); - m_ConfigRpcEndpoint = make_shared(); + m_ConfigRpcEndpoint = boost::make_shared(); 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(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& ea) +void ConfigRpcComponent::LocalObjectCommittedHandler(const ObjectSetEventArgs& 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& ea) +void ConfigRpcComponent::LocalObjectRemovedHandler(const ObjectSetEventArgs& 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(¶ms)) - 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(properties.GetDictionary()); + object = boost::make_shared(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(¶ms)) - 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); diff --git a/components/configrpc/configrpccomponent.h b/components/configrpc/configrpccomponent.h index 2ae882d6a..35d9fd875 100644 --- a/components/configrpc/configrpccomponent.h +++ b/components/configrpc/configrpccomponent.h @@ -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& ea); - int LocalObjectRemovedHandler(const ObjectSetEventArgs& ea); + void LocalObjectCommittedHandler(const ObjectSetEventArgs& ea); + void LocalObjectRemovedHandler(const ObjectSetEventArgs& 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); diff --git a/components/delegation/delegationcomponent.cpp b/components/delegation/delegationcomponent.cpp index f68a896d3..91cf71156 100644 --- a/components/delegation/delegationcomponent.cpp +++ b/components/delegation/delegationcomponent.cpp @@ -28,18 +28,18 @@ string DelegationComponent::GetName(void) const void DelegationComponent::Start(void) { - m_AllServices = make_shared(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::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(); + m_DelegationTimer = boost::make_shared(); 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(); + m_DelegationEndpoint = boost::make_shared(); 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& ea) +void DelegationComponent::NewServiceHandler(const ObjectSetEventArgs& ea) { AssignService(ea.Target); - return 0; } -int DelegationComponent::RemovedServiceHandler(const ObjectSetEventArgs& ea) +void DelegationComponent::RemovedServiceHandler(const ObjectSetEventArgs& 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); diff --git a/components/delegation/delegationcomponent.h b/components/delegation/delegationcomponent.h index b4221b28e..db8070701 100644 --- a/components/delegation/delegationcomponent.h +++ b/components/delegation/delegationcomponent.h @@ -38,18 +38,16 @@ private: ConfigObject::Set::Ptr m_AllServices; Timer::Ptr m_DelegationTimer; - int NewServiceHandler(const ObjectSetEventArgs& ea); - int RemovedServiceHandler(const ObjectSetEventArgs& ea); + void NewServiceHandler(const ObjectSetEventArgs& ea); + void RemovedServiceHandler(const ObjectSetEventArgs& 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); }; } diff --git a/components/demo/democomponent.cpp b/components/demo/democomponent.cpp index ce8449be2..f08272ec2 100644 --- a/components/demo/democomponent.cpp +++ b/components/demo/democomponent.cpp @@ -36,15 +36,15 @@ string DemoComponent::GetName(void) const */ void DemoComponent::Start(void) { - m_DemoEndpoint = make_shared(); + m_DemoEndpoint = boost::make_shared(); 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(); + m_DemoTimer = boost::make_shared(); 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); diff --git a/components/demo/democomponent.h b/components/demo/democomponent.h index a9334b341..e6341558f 100644 --- a/components/demo/democomponent.h +++ b/components/demo/democomponent.h @@ -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); }; } diff --git a/components/discovery/discoverycomponent.cpp b/components/discovery/discoverycomponent.cpp index 616f2791b..1bf293c6b 100644 --- a/components/discovery/discoverycomponent.cpp +++ b/components/discovery/discoverycomponent.cpp @@ -36,28 +36,28 @@ string DiscoveryComponent::GetName(void) const */ void DiscoveryComponent::Start(void) { - m_DiscoveryEndpoint = make_shared(); + m_DiscoveryEndpoint = boost::make_shared(); 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(); + m_DiscoveryTimer = boost::make_shared(); 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(); - GetEndpointManager()->ForEachEndpoint(bind(&DiscoveryComponent::DiscoveryEndpointHandler, this, _1, *info)); + *info = boost::make_shared(); + 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(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::Ptr info = boost::make_shared(); 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); diff --git a/components/discovery/discoverycomponent.h b/components/discovery/discoverycomponent.h index 75bc0ea5e..3e3ec83a9 100644 --- a/components/discovery/discoverycomponent.h +++ b/components/discovery/discoverycomponent.h @@ -56,23 +56,23 @@ private: map 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 index 1390ee581..000000000 --- a/config/ax_cxx_compile_stdcxx_0x.m4 +++ /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 -# -# 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 - struct check - { - static_assert(sizeof(int) <= sizeof(T), "not big enough"); - }; - - typedef check> right_angle_brackets; - - int a; - decltype(a) b; - - typedef check check_type; - check_type c; - check_type&& cr = static_cast(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 - struct check - { - static_assert(sizeof(int) <= sizeof(T), "not big enough"); - }; - - typedef check> right_angle_brackets; - - int a; - decltype(a) b; - - typedef check check_type; - check_type c; - check_type&& cr = static_cast(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 - struct check - { - static_assert(sizeof(int) <= sizeof(T), "not big enough"); - }; - - typedef check> right_angle_brackets; - - int a; - decltype(a) b; - - typedef check check_type; - check_type c; - check_type&& cr = static_cast(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 -]) diff --git a/configure.ac b/configure.ac index 11f7b0db1..e6ea1d9bd 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/dyn/config_parser.cc b/dyn/config_parser.cc index d18795ac8..f2bfca17a 100644 --- a/dyn/config_parser.cc +++ b/dyn/config_parser.cc @@ -1578,7 +1578,7 @@ yyreduce: /* Line 1806 of yacc.c */ #line 120 "config_parser.yy" { - m_Object = make_shared((yyvsp[(4) - (5)].text), (yyvsp[(5) - (5)].text), yylloc); + m_Object = boost::make_shared((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()); + m_ExpressionLists.push(boost::make_shared()); } break; @@ -1681,7 +1681,7 @@ yyreduce: free((yyvsp[(3) - (6)].text)); delete (yyvsp[(6) - (6)].variant); - ExpressionList::Ptr subexprl = make_shared(); + ExpressionList::Ptr subexprl = boost::make_shared(); 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(); + m_Array = boost::make_shared(); } break; diff --git a/dyn/config_parser.yy b/dyn/config_parser.yy index 2ca7aab25..58fd273a8 100644 --- a/dyn/config_parser.yy +++ b/dyn/config_parser.yy @@ -118,7 +118,7 @@ object: } attributes T_OBJECT T_IDENTIFIER T_STRING { - m_Object = make_shared($4, $5, yylloc); + m_Object = boost::make_shared($4, $5, yylloc); free($4); free($5); } @@ -178,7 +178,7 @@ inherits_specifier: /* empty */ expressionlist: '{' { - m_ExpressionLists.push(make_shared()); + m_ExpressionLists.push(boost::make_shared()); } expressions '}' @@ -207,7 +207,7 @@ expression: T_IDENTIFIER operator value free($3); delete $6; - ExpressionList::Ptr subexprl = make_shared(); + ExpressionList::Ptr subexprl = boost::make_shared(); subexprl->AddExpression(subexpr); Expression expr($1, OperatorPlus, subexprl, yylloc); @@ -259,7 +259,7 @@ value: simplevalue tuple: '(' { - m_Array = make_shared(); + m_Array = boost::make_shared(); } tupleitems ')' diff --git a/dyn/configcompiler.cpp b/dyn/configcompiler.cpp index 978f86b17..08271920b 100644 --- a/dyn/configcompiler.cpp +++ b/dyn/configcompiler.cpp @@ -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(m_Input->gcount()); } void *ConfigCompiler::GetScanner(void) const diff --git a/dyn/configitem.cpp b/dyn/configitem.cpp index 43eca579e..24dde96c6 100644 --- a/dyn/configitem.cpp +++ b/dyn/configitem.cpp @@ -79,7 +79,7 @@ ObjectSet::Ptr ConfigItem::GetAllObjects(void) static ObjectSet::Ptr allObjects; if (!allObjects) { - allObjects = make_shared >(); + allObjects = boost::make_shared >(); allObjects->Start(); } @@ -98,7 +98,7 @@ ConfigItem::TNMap::Ptr ConfigItem::GetObjectsByTypeAndName(void) static ConfigItem::TNMap::Ptr tnmap; if (!tnmap) { - tnmap = make_shared(GetAllObjects(), &ConfigItem::GetTypeAndName); + tnmap = boost::make_shared(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::Ptr properties = boost::make_shared(); CalculateProperties(properties); if (!dobj) dobj = ConfigObject::GetObject(GetType(), GetName()); if (!dobj) - dobj = make_shared(properties); + dobj = boost::make_shared(properties); else dobj->SetProperties(properties); diff --git a/dyn/expression.cpp b/dyn/expression.cpp index 4c7b08ac8..64413f1dc 100644 --- a/dyn/expression.cpp +++ b/dyn/expression.cpp @@ -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::Ptr dict = boost::make_shared(); 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(); + dict = boost::make_shared(); } exprl->Execute(dict); diff --git a/dyn/i2-dyn.h b/dyn/i2-dyn.h index ce20b737c..3db7e0e93 100644 --- a/dyn/i2-dyn.h +++ b/dyn/i2-dyn.h @@ -32,6 +32,12 @@ #include #include +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 */ diff --git a/dyntest/dyntest.cpp b/dyntest/dyntest.cpp index e114ce79f..3f2c4b35c 100644 --- a/dyntest/dyntest.cpp +++ b/dyntest/dyntest.cpp @@ -1,6 +1,9 @@ #include //#include +using std::cout; +using std::endl; + using namespace icinga; int main(int argc, char **argv) diff --git a/icinga-app/icinga.cpp b/icinga-app/icinga.cpp index 96dd96794..ce482686c 100644 --- a/icinga-app/icinga.cpp +++ b/icinga-app/icinga.cpp @@ -38,6 +38,6 @@ int main(int argc, char **argv) LTDL_SET_PRELOADED_SYMBOLS(); #endif /* _WIN32 */ - IcingaApplication::Ptr instance = make_shared(); + IcingaApplication::Ptr instance = boost::make_shared(); return instance->Run(argc, argv); } diff --git a/icinga/endpointmanager.cpp b/icinga/endpointmanager.cpp index 483dd75b5..fa310c542 100644 --- a/icinga/endpointmanager.cpp +++ b/icinga/endpointmanager.cpp @@ -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(m_SSLContext); + JsonRpcServer::Ptr server = boost::make_shared(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::Ptr endpoint = boost::make_shared(); 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::Ptr endpoint = boost::make_shared(); endpoint->SetClient(static_pointer_cast(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 callback) +void EndpointManager::ForEachEndpoint(function 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 callback, time_t timeout) + function callback, time_t timeout) { m_NextMessageID++; @@ -326,8 +324,8 @@ void EndpointManager::RescheduleRequestTimer(void) &EndpointManager::RequestTimeoutLessComparer); if (!m_RequestTimer) { - m_RequestTimer = make_shared(); - m_RequestTimer->OnTimerExpired.connect(bind(&EndpointManager::RequestTimerHandler, this, _1)); + m_RequestTimer = boost::make_shared(); + 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::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) diff --git a/icinga/endpointmanager.h b/icinga/endpointmanager.h index 3a9ac354c..8636f1e8b 100644 --- a/icinga/endpointmanager.h +++ b/icinga/endpointmanager.h @@ -44,7 +44,7 @@ struct I2_ICINGA_API PendingRequest { time_t Timeout; RequestMessage Request; - function Callback; + function 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 callback, time_t timeout = 10); + function callback, time_t timeout = 10); void ProcessResponseMessage(const Endpoint::Ptr& sender, const ResponseMessage& message); - void ForEachEndpoint(function callback); + void ForEachEndpoint(function callback); Endpoint::Ptr GetEndpointByIdentity(string identity) const; @@ -123,9 +123,9 @@ private: static bool RequestTimeoutLessComparer(const pair& a, const pair& b); void RescheduleRequestTimer(void); - int RequestTimerHandler(const TimerEventArgs& ea); + void RequestTimerHandler(void); - int NewClientHandler(const NewClientEventArgs& ncea); + void NewClientHandler(const NewClientEventArgs& ncea); }; } diff --git a/icinga/icingaapplication.cpp b/icinga/icingaapplication.cpp index 18d3f3676..4780298e7 100644 --- a/icinga/icingaapplication.cpp +++ b/icinga/icingaapplication.cpp @@ -37,31 +37,33 @@ using namespace icinga; int IcingaApplication::Main(const vector& 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] << " " << endl; + stringstream msgbuf; + msgbuf << "Syntax: " << args[0] << " "; + Application::Log(LogInformation, "icinga", msgbuf.str()); return EXIT_FAILURE; } - m_EndpointManager = make_shared(); + m_EndpointManager = boost::make_shared(); string componentDirectory = GetExeDirectory() + "/../lib/icinga2"; AddComponentSearchDir(componentDirectory); /* register handler for 'component' config objects */ - static ConfigObject::Set::Ptr componentObjects = make_shared(ConfigObject::GetAllObjects(), ConfigObject::MakeTypePredicate("component")); - function&)> NewComponentHandler = bind(&IcingaApplication::NewComponentHandler, this, _1); + static ConfigObject::Set::Ptr componentObjects = boost::make_shared(ConfigObject::GetAllObjects(), ConfigObject::MakeTypePredicate("component")); + function&)> 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("component", "configfile"); + ConfigObject::Ptr fileComponentConfig = boost::make_shared("component", "configfile"); fileComponentConfig->SetLocal(true); fileComponentConfig->SetProperty("configFilename", args[1]); fileComponentConfig->Commit(); @@ -84,7 +86,7 @@ int IcingaApplication::Main(const vector& args) /* set up SSL context */ shared_ptr 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 sslContext = Utility::MakeSSLContext(GetPublicKeyFile(), GetPrivateKeyFile(), GetCAKeyFile()); @@ -111,7 +113,7 @@ EndpointManager::Ptr IcingaApplication::GetEndpointManager(void) return m_EndpointManager; } -int IcingaApplication::NewComponentHandler(const ObjectSetEventArgs& ea) +void IcingaApplication::NewComponentHandler(const ObjectSetEventArgs& ea) { ConfigObject::Ptr object = ea.Target; @@ -129,18 +131,14 @@ int IcingaApplication::NewComponentHandler(const ObjectSetEventArgs& ea) +void IcingaApplication::DeletedComponentHandler(const ObjectSetEventArgs& ea) { ConfigObject::Ptr object = ea.Target; Component::Ptr component = GetComponent(object->GetName()); UnregisterComponent(component); - - return 0; } string IcingaApplication::GetPrivateKeyFile(void) const diff --git a/icinga/icingaapplication.h b/icinga/icingaapplication.h index de6b82b0e..6b928d129 100644 --- a/icinga/icingaapplication.h +++ b/icinga/icingaapplication.h @@ -53,14 +53,8 @@ private: string m_Node; string m_Service; - int NewComponentHandler(const ObjectSetEventArgs& ea); - int DeletedComponentHandler(const ObjectSetEventArgs& 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& ea); + void DeletedComponentHandler(const ObjectSetEventArgs& ea); }; } diff --git a/icinga/jsonrpcendpoint.cpp b/icinga/jsonrpcendpoint.cpp index 02442ccf9..594141c6a 100644 --- a/icinga/jsonrpcendpoint.cpp +++ b/icinga/jsonrpcendpoint.cpp @@ -36,7 +36,7 @@ JsonRpcClient::Ptr JsonRpcEndpoint::GetClient(void) void JsonRpcEndpoint::Connect(string node, string service, shared_ptr sslContext) { - JsonRpcClient::Ptr client = make_shared(RoleOutbound, sslContext); + JsonRpcClient::Ptr client = boost::make_shared(RoleOutbound, sslContext); SetClient(client); client->Connect(node, service); client->Start(); @@ -45,10 +45,10 @@ void JsonRpcEndpoint::Connect(string node, string service, shared_ptr 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(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) diff --git a/icinga/jsonrpcendpoint.h b/icinga/jsonrpcendpoint.h index 7601e1eb9..2c07eb54e 100644 --- a/icinga/jsonrpcendpoint.h +++ b/icinga/jsonrpcendpoint.h @@ -58,10 +58,10 @@ private: JsonRpcClient::Ptr m_Client; map 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); }; } diff --git a/icinga/nagioschecktask.cpp b/icinga/nagioschecktask.cpp index f6adac5b1..26868806b 100644 --- a/icinga/nagioschecktask.cpp +++ b/icinga/nagioschecktask.cpp @@ -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(service); + return boost::make_shared(service); } diff --git a/icinga/virtualendpoint.cpp b/icinga/virtualendpoint.cpp index ca4951eec..8737d9ff3 100644 --- a/icinga/virtualendpoint.cpp +++ b/icinga/virtualendpoint.cpp @@ -38,7 +38,7 @@ bool VirtualEndpoint::IsConnected(void) const return true; } -void VirtualEndpoint::RegisterTopicHandler(string topic, function callback) +void VirtualEndpoint::RegisterTopicHandler(string topic, function callback) { map > >::iterator it; it = m_TopicHandlers.find(topic); @@ -46,7 +46,7 @@ void VirtualEndpoint::RegisterTopicHandler(string topic, function > sig; if (it == m_TopicHandlers.end()) { - sig = make_shared >(); + sig = boost::make_shared >(); m_TopicHandlers.insert(make_pair(topic, sig)); } else { sig = it->second; @@ -57,7 +57,7 @@ void VirtualEndpoint::RegisterTopicHandler(string topic, function callback) +void VirtualEndpoint::UnregisterTopicHandler(string topic, function callback) { // TODO: implement //m_TopicHandlers[method] -= callback; diff --git a/icinga/virtualendpoint.h b/icinga/virtualendpoint.h index 19f1ecfa2..9e42f34a9 100644 --- a/icinga/virtualendpoint.h +++ b/icinga/virtualendpoint.h @@ -45,8 +45,8 @@ public: typedef shared_ptr Ptr; typedef weak_ptr WeakPtr; - void RegisterTopicHandler(string topic, function callback); - void UnregisterTopicHandler(string topic, function callback); + void RegisterTopicHandler(string topic, function callback); + void UnregisterTopicHandler(string topic, function callback); virtual string GetAddress(void) const; diff --git a/jsonrpc/jsonrpcclient.cpp b/jsonrpc/jsonrpcclient.cpp index 5cfa76749..e7ce12ce2 100644 --- a/jsonrpc/jsonrpcclient.cpp +++ b/jsonrpc/jsonrpcclient.cpp @@ -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 sslContext) { - return make_shared(role, sslContext); + return boost::make_shared(role, sslContext); } diff --git a/jsonrpc/jsonrpcclient.h b/jsonrpc/jsonrpcclient.h index 463481aa5..384dff3c4 100644 --- a/jsonrpc/jsonrpcclient.h +++ b/jsonrpc/jsonrpcclient.h @@ -53,7 +53,7 @@ public: boost::signal OnNewMessage; private: - int DataAvailableHandler(const EventArgs&); + void DataAvailableHandler(const EventArgs&); }; JsonRpcClient::Ptr JsonRpcClientFactory(TcpClientRole role, shared_ptr sslContext); diff --git a/jsonrpc/jsonrpcserver.cpp b/jsonrpc/jsonrpcserver.cpp index 77bb9e474..a39d2c594 100644 --- a/jsonrpc/jsonrpcserver.cpp +++ b/jsonrpc/jsonrpcserver.cpp @@ -28,5 +28,5 @@ using namespace icinga; */ JsonRpcServer::JsonRpcServer(shared_ptr sslContext) { - SetClientFactory(bind(&JsonRpcClientFactory, RoleInbound, sslContext)); + SetClientFactory(boost::bind(&JsonRpcClientFactory, RoleInbound, sslContext)); } diff --git a/jsonrpc/messagepart.cpp b/jsonrpc/messagepart.cpp index ee405c081..0f1cf1f11 100644 --- a/jsonrpc/messagepart.cpp +++ b/jsonrpc/messagepart.cpp @@ -27,7 +27,7 @@ using namespace icinga; */ MessagePart::MessagePart(void) { - m_Dictionary = make_shared(); + m_Dictionary = boost::make_shared(); } /** @@ -76,7 +76,7 @@ MessagePart::MessagePart(const MessagePart& message) */ Dictionary::Ptr MessagePart::GetDictionaryFromJson(json_t *json) { - Dictionary::Ptr dictionary = make_shared(); + Dictionary::Ptr dictionary = boost::make_shared(); for (cJSON *i = json->child; i != NULL; i = i->next) { switch (i->type) { -- 2.40.0