MXS-2314 Ensure that connections are closed

As m_servers is a member of Monitor, it is better if the closing
of the MYSQL connections is done there, so that derived classes
do not need to remember doing that.
This commit is contained in:
Johan Wikman
2019-02-08 15:30:44 +02:00
parent dffb933efa
commit 6425d4ed0c
2 changed files with 22 additions and 18 deletions

View File

@ -210,9 +210,9 @@ public:
virtual bool start(const MXS_CONFIG_PARAMETER* params) = 0;
/**
* Stops the monitor. If the monitor uses a polling thread, the thread should be stopped.
* Stops the monitor.
*/
virtual void stop() = 0;
void stop();
/**
* Write diagnostic information to a DCB.
@ -320,6 +320,10 @@ public:
std::vector<MXS_MONITORED_SERVER*> m_servers; /**< Monitored servers */
protected:
/**
* Stop the monitor. If the monitor uses a polling thread, the thread should be stopped.
*/
virtual void do_stop() = 0;
/**
* Check if the monitor user can execute a query. The query should be such that it only succeeds if
@ -670,14 +674,7 @@ public:
*
* @return True, if the monitor started, false otherwise.
*/
bool start(const MXS_CONFIG_PARAMETER* params);
/**
* @brief Stops the monitor.
*
* When the function returns, the monitor has stopped.
*/
void stop();
bool start(const MXS_CONFIG_PARAMETER* params) final;
/**
* @brief Write diagnostics
@ -711,6 +708,8 @@ public:
protected:
MonitorWorker(const std::string& name, const std::string& module);
void do_stop() final;
/**
* @brief Should the monitor shut down?
*