Skip to content

Commit

Permalink
Fix crash in Dependency::Stop()
Browse files Browse the repository at this point in the history
This partially reverts the fix in #8436

fixes #8687
refs #8436

Conflicts:
	lib/db_ido_pgsql/idopgsqlconnection.cpp
  • Loading branch information
Michael Friedrich committed Mar 12, 2015
1 parent e1a07ad commit 64214bd
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 19 deletions.
17 changes: 9 additions & 8 deletions lib/base/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -310,11 +315,6 @@ void Application::RunEventLoop(void)
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();

Expand Down Expand Up @@ -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;
}

Expand Down
3 changes: 1 addition & 2 deletions lib/base/application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class I2_BASE_API Application : public ObjectImpl<Application> {

static void InstallExceptionHandlers(void);

static void RequestShutdown(int rc = 0);
static void RequestShutdown(void);
static void RequestRestart(void);
static void RequestReopenLogs(void);

Expand Down Expand Up @@ -162,7 +162,6 @@ class I2_BASE_API Application : public ObjectImpl<Application> {
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);
Expand Down
6 changes: 2 additions & 4 deletions lib/db_ido_mysql/idomysqlconnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
Expand Down
6 changes: 2 additions & 4 deletions lib/db_ido_pgsql/idopgsqlconnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion lib/remote/apilistener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 64214bd

Please sign in to comment.