MXS-1775 Thread starting is now handled by MonitorInstance

This commit is contained in:
Johan Wikman
2018-05-16 12:40:50 +03:00
parent adb7f156d6
commit c7eb0a9958
12 changed files with 48 additions and 243 deletions

View File

@ -2508,11 +2508,11 @@ namespace maxscale
MonitorInstance::MonitorInstance(MXS_MONITOR* pMonitor)
: m_status(0)
, m_thread(0)
, m_monitor(pMonitor)
, m_shutdown(0)
, m_script(NULL)
, m_events(0)
, m_thread(0)
{
}
@ -2535,6 +2535,48 @@ void MonitorInstance::stop()
m_script = NULL;
}
bool MonitorInstance::start(const MXS_CONFIG_PARAMETER* pParams)
{
bool started = false;
ss_dassert(!m_shutdown);
ss_dassert(!m_thread);
ss_dassert(!m_script);
if (!m_checked)
{
if (!has_sufficient_permissions())
{
MXS_ERROR("Failed to start monitor. See earlier errors for more information.");
}
else
{
m_checked = true;
}
}
if (m_checked)
{
m_script = config_copy_string(pParams, "script");
m_events = config_get_enum(pParams, "events", mxs_monitor_event_enum_values);
configure(pParams);
if (thread_start(&m_thread, &maxscale::MonitorInstance::main, this, 0) == NULL)
{
MXS_ERROR("Failed to start monitor thread for monitor '%s'.", m_monitor->name);
MXS_FREE(m_script);
m_script = NULL;
}
else
{
started = true;
}
}
return started;
}
bool MonitorInstance::has_sufficient_permissions() const
{
return true;