MXS-1848 Introduce a specific monitor type

Instead of using void there's now a MXS_SPECIFIC_MONITOR struct
from which monitor specific types can be derived. This change
does not bring about other benefits than a bit of clarity but
this is the first step in clearing up the monitor API.
This commit is contained in:
Johan Wikman
2018-05-04 10:02:06 +03:00
parent 1f6cc6db8a
commit d4008f7b28
11 changed files with 34 additions and 30 deletions

View File

@ -30,7 +30,8 @@ static void monitorMain(void *);
/*lint +e14 */
static void *startMonitor(MXS_MONITOR *, const MXS_CONFIG_PARAMETER *params);
static MXS_SPECIFIC_MONITOR *startMonitor(MXS_MONITOR *,
const MXS_CONFIG_PARAMETER *params);
static void stopMonitor(MXS_MONITOR *);
static void diagnostics(DCB *, const MXS_MONITOR *);
static json_t* diagnostics_json(const MXS_MONITOR *);
@ -105,7 +106,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
*
* @return A handle to use when interacting with the monitor
*/
static void *
static MXS_SPECIFIC_MONITOR *
startMonitor(MXS_MONITOR *mon, const MXS_CONFIG_PARAMETER *params)
{
NDBC_MONITOR *handle = static_cast<NDBC_MONITOR*>(mon->handle);

View File

@ -18,7 +18,7 @@
#include <maxscale/thread.h>
// The handle for an instance of a NDB Cluster Monitor module
typedef struct
struct NDBC_MONITOR : public MXS_SPECIFIC_MONITOR
{
THREAD thread; /**< Monitor thread */
SPINLOCK lock; /**< The monitor spinlock */
@ -29,4 +29,4 @@ typedef struct
MXS_MONITORED_SERVER *master; /**< Master server for MySQL Master/Slave replication */
char* script; /*< Script to call when state changes occur on servers */
MXS_MONITOR* monitor;
} NDBC_MONITOR;
};