MXS-1775 Move status management to MonitorInstance
This commit is contained in:
parent
1e084b78b1
commit
15e3a2887c
@ -40,7 +40,6 @@ protected:
|
||||
|
||||
static void main(void* pArg);
|
||||
|
||||
int m_status; /**< The current status of the monitor. */
|
||||
MXS_MONITOR* m_monitor; /**< The generic monitor structure. */
|
||||
int32_t m_shutdown; /**< Non-zero if the monitor should shut down. */
|
||||
std::string m_script; /**< Launchable script. */
|
||||
@ -48,6 +47,7 @@ protected:
|
||||
bool m_checked; /**< Whether server access has been checked. */
|
||||
|
||||
private:
|
||||
int32_t m_status; /**< The current status of the monitor. */
|
||||
THREAD m_thread; /**< The thread handle of the monitoring thread. */
|
||||
};
|
||||
|
||||
|
@ -2507,10 +2507,10 @@ namespace maxscale
|
||||
{
|
||||
|
||||
MonitorInstance::MonitorInstance(MXS_MONITOR* pMonitor)
|
||||
: m_status(0)
|
||||
, m_monitor(pMonitor)
|
||||
: m_monitor(pMonitor)
|
||||
, m_shutdown(0)
|
||||
, m_events(0)
|
||||
, m_status(MXS_MONITOR_STOPPED)
|
||||
, m_thread(0)
|
||||
{
|
||||
}
|
||||
@ -2522,10 +2522,14 @@ MonitorInstance::~MonitorInstance()
|
||||
|
||||
void MonitorInstance::stop()
|
||||
{
|
||||
// This is always called in single-thread context.
|
||||
ss_dassert(m_thread);
|
||||
ss_dassert(m_status == MXS_MONITOR_RUNNING);
|
||||
|
||||
atomic_store_int32(&m_status, MXS_MONITOR_STOPPING);
|
||||
atomic_store_int32(&m_shutdown, 1);
|
||||
thread_wait(m_thread);
|
||||
|
||||
m_thread = 0;
|
||||
m_shutdown = 0;
|
||||
}
|
||||
@ -2581,7 +2585,11 @@ void MonitorInstance::configure(const MXS_CONFIG_PARAMETER* pParams)
|
||||
//static
|
||||
void MonitorInstance::main(void* pArg)
|
||||
{
|
||||
MonitorInstance* pThis = static_cast<MonitorInstance*>(pArg);
|
||||
|
||||
atomic_store_int32(&pThis->m_status, MXS_MONITOR_RUNNING);
|
||||
static_cast<MonitorInstance*>(pArg)->main();
|
||||
atomic_store_int32(&pThis->m_status, MXS_MONITOR_STOPPED);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -463,16 +463,14 @@ void GaleraMonitor::main()
|
||||
MXS_ERROR("mysql_thread_init failed in monitor module. Exiting.");
|
||||
return;
|
||||
}
|
||||
m_status = MXS_MONITOR_RUNNING;
|
||||
|
||||
load_server_journal(m_monitor, NULL);
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (m_shutdown)
|
||||
{
|
||||
m_status = MXS_MONITOR_STOPPING;
|
||||
mysql_thread_end();
|
||||
m_status = MXS_MONITOR_STOPPED;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -455,16 +455,13 @@ void MMMonitor::main()
|
||||
return;
|
||||
}
|
||||
|
||||
m_status = MXS_MONITOR_RUNNING;
|
||||
load_server_journal(mon, &m_master);
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (m_shutdown)
|
||||
{
|
||||
m_status = MXS_MONITOR_STOPPING;
|
||||
mysql_thread_end();
|
||||
m_status = MXS_MONITOR_STOPPED;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -255,16 +255,13 @@ void NDBCMonitor::main()
|
||||
return;
|
||||
}
|
||||
|
||||
m_status = MXS_MONITOR_RUNNING;
|
||||
load_server_journal(m_monitor, NULL);
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (m_shutdown)
|
||||
{
|
||||
m_status = MXS_MONITOR_STOPPING;
|
||||
mysql_thread_end();
|
||||
m_status = MXS_MONITOR_STOPPED;
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user