]> granicus.if.org Git - icinga2/commitdiff
Fix crash in Dependency::Stop()
authorMichael Friedrich <michael.friedrich@netways.de>
Thu, 12 Mar 2015 10:43:04 +0000 (11:43 +0100)
committerMichael Friedrich <michael.friedrich@netways.de>
Thu, 12 Mar 2015 10:56:20 +0000 (11:56 +0100)
This partially reverts the fix in #8436

fixes #8687
refs #8436

Conflicts:
lib/db_ido_pgsql/idopgsqlconnection.cpp

lib/base/application.cpp
lib/base/application.hpp
lib/db_ido_mysql/idomysqlconnection.cpp
lib/db_ido_pgsql/idopgsqlconnection.cpp
lib/remote/apilistener.cpp

index 7ce329e24a63b8c47b9c0d9d1a5caffd6f960f81..4d72652b4f422171ea842399bad624e0eb0a7b7a 100644 (file)
@@ -57,7 +57,6 @@ static bool l_InExceptionHandler = false;
 int Application::m_ArgC;
 char **Application::m_ArgV;
 double Application::m_StartTime;
-int Application::m_ExitStatus = 0;
 
 /**
  * Constructor for the Application class.
@@ -107,6 +106,12 @@ Application::~Application(void)
 
 void Application::Exit(int rc)
 {
+       if (rc)
+               Log(LogCritical, "Application")
+                   << "Shutting down after a fatal error; exit code: " << rc;
+       else
+               Log(LogInformation, "Application", "Shutting down...");
+
        std::cout.flush();
 
        BOOST_FOREACH(const Logger::Ptr& logger, Logger::GetLoggers()) {
@@ -310,11 +315,6 @@ mainloop:
                goto mainloop;
        }
 
-       if (m_ExitStatus)
-               Log(LogInformation, "Application", "Shutting down Icinga after a fatal error.");
-       else
-               Log(LogInformation, "Application", "Shutting down Icinga...");
-
        DynamicObject::StopObjects();
        Application::GetInstance()->OnShutdown();
 
@@ -361,9 +361,10 @@ pid_t Application::StartReloadProcess(void)
  * Signals the application to shut down during the next
  * execution of the event loop.
  */
-void Application::RequestShutdown(int rc)
+void Application::RequestShutdown(void)
 {
-       m_ExitStatus = rc > m_ExitStatus ? rc : m_ExitStatus;
+       Log(LogInformation, "Application", "Received request to shut down.");
+
        m_ShuttingDown = true;
 }
 
index bc2b73a1ba7cfaeccb30f7d3b5fd97362f6e63ad..37bf6aa99a6fc75edffa6784524f04f220dd7bda 100644 (file)
@@ -69,7 +69,7 @@ public:
 
        static void InstallExceptionHandlers(void);
 
-       static void RequestShutdown(int rc = 0);
+       static void RequestShutdown(void);
        static void RequestRestart(void);
        static void RequestReopenLogs(void);
 
@@ -162,7 +162,6 @@ private:
        static bool m_Debugging; /**< Whether debugging is enabled. */
        static LogSeverity m_DebuggingSeverity; /**< Whether debugging severity is set. */
        static double m_StartTime;
-       static int m_ExitStatus;
 
 #ifndef _WIN32
        static void SigIntTermHandler(int signum);
index 153b11e34ab273ad65f4a79ea91b3329a8f8fd06..95dd45183c60c4d33d4d5ecc78aec5e78220965a 100644 (file)
@@ -225,8 +225,7 @@ void IdoMysqlConnection::Reconnect(void)
                if (!row) {
                        Log(LogCritical, "IdoMysqlConnection", "Schema does not provide any valid version! Verify your schema installation.");
 
-                       Application::RequestShutdown(EXIT_FAILURE);
-                       return;
+                       Application::Exit(EXIT_FAILURE);
                }
 
                DiscardRows(result);
@@ -238,8 +237,7 @@ void IdoMysqlConnection::Reconnect(void)
                            << "Schema version '" << version << "' does not match the required version '"
                            << SCHEMA_VERSION << "'! Please check the upgrade documentation.";
 
-                       Application::RequestShutdown(EXIT_FAILURE);
-                       return;
+                       Application::Exit(EXIT_FAILURE);
                }
 
                String instanceName = GetInstanceName();
index d3c79643687f54a14d6becc72153fdbf933b1ec1..fca4e8f84296927b107271f9798eb420eb25bac1 100644 (file)
@@ -228,8 +228,7 @@ void IdoPgsqlConnection::Reconnect(void)
 
                        Log(LogCritical, "IdoPgsqlConnection", "Schema does not provide any valid version! Verify your schema installation.");
 
-                       Application::RequestShutdown(EXIT_FAILURE);
-                       return;
+                       Application::Exit(EXIT_FAILURE);
                }
 
                String version = row->Get("version");
@@ -242,8 +241,7 @@ void IdoPgsqlConnection::Reconnect(void)
                            << "Schema version '" << version << "' does not match the required version '"
                            << SCHEMA_VERSION << "'! Please check the upgrade documentation.";
 
-                       Application::RequestShutdown(EXIT_FAILURE);
-                       return;
+                       Application::Exit(EXIT_FAILURE);
                }
 
                String instanceName = GetInstanceName();
index 7fe35b5c9725c01f1c5ef39061f7ba5d0c4e47c8..42042270a211b2da8f22d434c04da4dfadd979c0 100644 (file)
@@ -110,7 +110,7 @@ void ApiListener::Start(void)
        if (!AddListener(GetBindHost(), GetBindPort())) {
                Log(LogCritical, "ApiListener")
                     << "Cannot add listener on host '" << GetBindHost() << "' for port '" << GetBindPort() << "'.";
-               Application::RequestShutdown(EXIT_FAILURE);
+               Application::Exit(EXIT_FAILURE);
        }
 
        m_Timer = new Timer();