MXS-1775 MonitorInstance now calls mysql_thread_[init|finish]()

This commit is contained in:
Johan Wikman
2018-05-16 14:29:44 +03:00
parent 15e3a2887c
commit 6db4ce54a9
6 changed files with 16 additions and 39 deletions

View File

@ -2587,9 +2587,22 @@ void MonitorInstance::main(void* pArg)
{ {
MonitorInstance* pThis = static_cast<MonitorInstance*>(pArg); MonitorInstance* pThis = static_cast<MonitorInstance*>(pArg);
atomic_store_int32(&pThis->m_status, MXS_MONITOR_RUNNING); if (mysql_thread_init() == 0)
static_cast<MonitorInstance*>(pArg)->main(); {
atomic_store_int32(&pThis->m_status, MXS_MONITOR_STOPPED); atomic_store_int32(&pThis->m_status, MXS_MONITOR_RUNNING);
static_cast<MonitorInstance*>(pArg)->main();
atomic_store_int32(&pThis->m_status, MXS_MONITOR_STOPPED);
mysql_thread_end();
}
else
{
MXS_ERROR("mysql_thread_init() failed for %s. The monitor cannot start.",
pThis->m_monitor->name);
// TODO: MaxScale now thinks the monitor is running, as startMonitor()
// TODO: already returned true.
}
} }
} }

View File

@ -121,12 +121,6 @@ void update_server_status(MXS_MONITOR *monitor, MXS_MONITORED_SERVER *database)
*/ */
void AuroraMonitor::main() void AuroraMonitor::main()
{ {
if (mysql_thread_init())
{
MXS_ERROR("mysql_thread_init failed in Aurora monitor. Exiting.");
return;
}
load_server_journal(m_monitor, NULL); load_server_journal(m_monitor, NULL);
while (!m_shutdown) while (!m_shutdown)
@ -168,8 +162,6 @@ void AuroraMonitor::main()
ms += MXS_MON_BASE_INTERVAL_MS; ms += MXS_MON_BASE_INTERVAL_MS;
} }
} }
mysql_thread_end();
} }
bool AuroraMonitor::has_sufficient_permissions() const bool AuroraMonitor::has_sufficient_permissions() const

View File

@ -458,11 +458,6 @@ void GaleraMonitor::main()
int log_no_members = 1; int log_no_members = 1;
master_stickiness = m_disableMasterFailback; master_stickiness = m_disableMasterFailback;
if (mysql_thread_init())
{
MXS_ERROR("mysql_thread_init failed in monitor module. Exiting.");
return;
}
load_server_journal(m_monitor, NULL); load_server_journal(m_monitor, NULL);
@ -470,7 +465,6 @@ void GaleraMonitor::main()
{ {
if (m_shutdown) if (m_shutdown)
{ {
mysql_thread_end();
return; return;
} }

View File

@ -185,12 +185,6 @@ static void update_server_status(MXS_MONITOR* monitor, MXS_MONITORED_SERVER* ser
void GRMon::main() void GRMon::main()
{ {
if (mysql_thread_init())
{
MXS_ERROR("mysql_thread_init failed. Exiting.");
return;
}
load_server_journal(m_monitor, NULL); load_server_journal(m_monitor, NULL);
while (!m_shutdown) while (!m_shutdown)
@ -229,8 +223,6 @@ void GRMon::main()
ms += MXS_MON_BASE_INTERVAL_MS; ms += MXS_MON_BASE_INTERVAL_MS;
} }
} }
mysql_thread_end();
} }
/** /**

View File

@ -449,19 +449,12 @@ void MMMonitor::main()
detect_stale_master = m_detectStaleMaster; detect_stale_master = m_detectStaleMaster;
if (mysql_thread_init())
{
MXS_ERROR("Fatal : mysql_thread_init failed in monitor module. Exiting.");
return;
}
load_server_journal(mon, &m_master); load_server_journal(mon, &m_master);
while (1) while (1)
{ {
if (m_shutdown) if (m_shutdown)
{ {
mysql_thread_end();
return; return;
} }

View File

@ -249,19 +249,12 @@ void NDBCMonitor::main()
MXS_MONITORED_SERVER *ptr; MXS_MONITORED_SERVER *ptr;
size_t nrounds = 0; size_t nrounds = 0;
if (mysql_thread_init())
{
MXS_ERROR("Fatal : mysql_thread_init failed in monitor module. Exiting.");
return;
}
load_server_journal(m_monitor, NULL); load_server_journal(m_monitor, NULL);
while (1) while (1)
{ {
if (m_shutdown) if (m_shutdown)
{ {
mysql_thread_end();
return; return;
} }