]> granicus.if.org Git - icinga2/commitdiff
Fixed compilations errors.
authorGunnar Beutner <gunnar.beutner@netways.de>
Tue, 3 Apr 2012 17:10:51 +0000 (19:10 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Tue, 3 Apr 2012 17:19:49 +0000 (19:19 +0200)
Added some more debugging code.

base/Makefile.am
base/application.cpp
base/application.h
jsonrpc/connectionmanager.cpp

index 3113fbc8558b795e8e6aed3bb2845d8f79acbf24..6a0e01c00552e532da80c90193c146ce92dc16f8 100644 (file)
@@ -15,6 +15,7 @@ libbase_la_SOURCES =  \
        confighive.h \
        configobject.cpp \
        configobject.h \
+       cxx11-compat.h \
        delegate.h \
        event.h \
        exception.cpp \
index 3e63ebc2e393704d43a5ba0d81ca1e45ca9fc3ea..01840c581696a5dcf330908331b31dba669ac6da 100644 (file)
@@ -17,6 +17,9 @@ Application::Application(void)
        lt_dlinit();
 #endif /* _WIN32 */
 
+       char *debugging = getenv("_DEBUG");
+       m_Debugging = (debugging && strtol(debugging, NULL, 10) != 0);
+
        m_ShuttingDown = false;
        m_ConfigHive = make_shared<ConfigHive>();
 }
@@ -30,6 +33,8 @@ Application::~Application(void)
                i->second->Stop();
        }
 
+       m_Components.clear();
+
 #ifdef _WIN32
        WSACleanup();
 #else /* _WIN32 */
@@ -349,3 +354,8 @@ void Application::AddComponentSearchDir(const string& componentDirectory)
        lt_dladdsearchdir(componentDirectory.c_str());
 #endif /* _WIN32 */
 }
+
+bool Application::IsDebugging(void) const
+{
+       return m_Debugging;
+}
index b532a5d4d2862377f1e88b7ad4f32a0146da26a0..406cc8f6cb19c8cc51d8d094fd688bd2fff59d74 100644 (file)
@@ -13,6 +13,7 @@ private:
        ConfigHive::Ptr m_ConfigHive;
        map< string, shared_ptr<Component> > m_Components;
        vector<string> m_Arguments;
+       bool m_Debugging;
 
 public:
        typedef shared_ptr<Application> Ptr;
@@ -42,6 +43,8 @@ public:
        void AddComponentSearchDir(const string& componentDirectory);
 
        const string& GetExeDirectory(void);
+
+       bool IsDebugging(void) const;
 };
 
 template<class T>
@@ -58,32 +61,32 @@ int application_main(int argc, char **argv)
 
        Application::Instance->SetArguments(args);
 
-#ifndef _DEBUG
-       try {
-#endif /* !_DEBUG */
+       if (Application::Instance->IsDebugging()) {
                result = Application::Instance->Main(args);
-#ifndef _DEBUG
-       } catch (const Exception& ex) {
-               cout << "---" << endl;
+       } else {
+               try {
+                       result = Application::Instance->Main(args);
+               } catch (const Exception& ex) {
+                       cout << "---" << endl;
 
-               string klass = typeid(ex).name();
+                       string klass = typeid(ex).name();
 
-#ifdef HAVE_GCC_ABI_DEMANGLE
-               int status;
-               char *realname = abi::__cxa_demangle(klass.c_str(), 0, 0, &status);
+       #ifdef HAVE_GCC_ABI_DEMANGLE
+                       int status;
+                       char *realname = abi::__cxa_demangle(klass.c_str(), 0, 0, &status);
 
-               if (realname != NULL) {
-                       klass = string(realname);
-                       free(realname);
-               }
-#endif /* HAVE_GCC_ABI_DEMANGLE */
+                       if (realname != NULL) {
+                               klass = string(realname);
+                               free(realname);
+                       }
+       #endif /* HAVE_GCC_ABI_DEMANGLE */
 
-               cout << "Exception: " << klass << endl;
-               cout << "Message: " << ex.GetMessage() << endl;
+                       cout << "Exception: " << klass << endl;
+                       cout << "Message: " << ex.GetMessage() << endl;
 
-               return EXIT_FAILURE;
+                       return EXIT_FAILURE;
+               }
        }
-#endif /* !_DEBUG */
 
        Application::Instance.reset();
 
index c4a8566f320b0937fbd0e249d439c8283cd9bcfb..6f4f53bf229b2f1d9872127c4c211f90c23facf9 100644 (file)
@@ -71,7 +71,8 @@ void ConnectionManager::RegisterMethod(string method, function<int (NewMessageEv
 
 void ConnectionManager::UnregisterMethod(string method, function<int (NewMessageEventArgs::Ptr)> callback)
 {
-       m_Methods[method] -= callback;
+       // TODO: implement
+       //m_Methods[method] -= callback;
 }
 
 void ConnectionManager::SendMessage(JsonRpcMessage::Ptr message)