Merge branch 'release-1.0beta-refresh' into query_classifier_test
This commit is contained in:
@ -108,15 +108,10 @@ char *hostname = "localhost";
|
|||||||
char *port = "6603";
|
char *port = "6603";
|
||||||
char *user = "admin";
|
char *user = "admin";
|
||||||
char *passwd = NULL;
|
char *passwd = NULL;
|
||||||
int so, cmdlen;
|
int so;
|
||||||
char *cmd;
|
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
char c;
|
char c;
|
||||||
|
|
||||||
cmd = malloc(1);
|
|
||||||
*cmd = 0;
|
|
||||||
cmdlen = 1;
|
|
||||||
|
|
||||||
while ((c = getopt_long(argc, argv, "h:p:P:u:v?",
|
while ((c = getopt_long(argc, argv, "h:p:P:u:v?",
|
||||||
long_options, &option_index))
|
long_options, &option_index))
|
||||||
>= 0)
|
>= 0)
|
||||||
@ -180,13 +175,27 @@ char c;
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmdlen > 1)
|
if (optind < argc) {
|
||||||
{
|
int i, len = 0;
|
||||||
cmd[cmdlen - 2] = '\0'; /* Remove trailing space */
|
char *cmd;
|
||||||
|
|
||||||
|
for (i = optind; i < argc; i++) {
|
||||||
|
len += strlen(argv[i]) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd = malloc(len);
|
||||||
|
strcpy(cmd, argv[optind]);
|
||||||
|
for (i = optind +1; i < argc; i++) {
|
||||||
|
strcat(cmd, " ");
|
||||||
|
strcat(cmd, argv[i]);
|
||||||
|
}
|
||||||
|
|
||||||
if (access(cmd, R_OK) == 0)
|
if (access(cmd, R_OK) == 0)
|
||||||
DoSource(so, cmd);
|
DoSource(so, cmd);
|
||||||
else
|
else
|
||||||
sendCommand(so, cmd);
|
sendCommand(so, cmd);
|
||||||
|
|
||||||
|
free(cmd);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -391,7 +400,7 @@ char buf[20];
|
|||||||
* Send a comamnd using the MaxScaled protocol, display the return data
|
* Send a comamnd using the MaxScaled protocol, display the return data
|
||||||
* on standard output.
|
* on standard output.
|
||||||
*
|
*
|
||||||
* Input terminates with a lien containing jsut the text OK
|
* Input terminates with a lien containing just the text OK
|
||||||
*
|
*
|
||||||
* @param so The socket connect to MaxScale
|
* @param so The socket connect to MaxScale
|
||||||
* @param cmd The command to send
|
* @param cmd The command to send
|
||||||
@ -401,7 +410,7 @@ static int
|
|||||||
sendCommand(int so, char *cmd)
|
sendCommand(int so, char *cmd)
|
||||||
{
|
{
|
||||||
char buf[80];
|
char buf[80];
|
||||||
int i, j, newline = 0;
|
int i, j, newline = 1;
|
||||||
|
|
||||||
write(so, cmd, strlen(cmd));
|
write(so, cmd, strlen(cmd));
|
||||||
while (1)
|
while (1)
|
||||||
|
@ -1688,8 +1688,13 @@ static void log_flush_cb(
|
|||||||
static void unlink_pidfile(void)
|
static void unlink_pidfile(void)
|
||||||
{
|
{
|
||||||
if (strlen(pidfile)) {
|
if (strlen(pidfile)) {
|
||||||
if (unlink(pidfile)) {
|
if (unlink(pidfile))
|
||||||
fprintf(stderr, "MaxScale failed to remove pidfile %s: error %d, %s\n", pidfile, errno, strerror(errno));
|
{
|
||||||
|
fprintf(stderr,
|
||||||
|
"MaxScale failed to remove pidfile %s: error %d, %s\n",
|
||||||
|
pidfile,
|
||||||
|
errno,
|
||||||
|
strerror(errno));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
#include <hint.h>
|
#include <hint.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -60,8 +60,9 @@ MONITOR *mon;
|
|||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
mon->state = MONITOR_STATE_ALLOC;
|
||||||
mon->name = strdup(name);
|
mon->name = strdup(name);
|
||||||
|
|
||||||
if ((mon->module = load_module(module, MODULE_MONITOR)) == NULL)
|
if ((mon->module = load_module(module, MODULE_MONITOR)) == NULL)
|
||||||
{
|
{
|
||||||
LOGIF(LE, (skygw_log_write_flush(
|
LOGIF(LE, (skygw_log_write_flush(
|
||||||
@ -73,7 +74,8 @@ MONITOR *mon;
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
mon->handle = (*mon->module->startMonitor)(NULL);
|
mon->handle = (*mon->module->startMonitor)(NULL);
|
||||||
mon->state |= MONITOR_STATE_RUNNING;
|
mon->state = MONITOR_STATE_RUNNING;
|
||||||
|
|
||||||
spinlock_acquire(&monLock);
|
spinlock_acquire(&monLock);
|
||||||
mon->next = allMonitors;
|
mon->next = allMonitors;
|
||||||
allMonitors = mon;
|
allMonitors = mon;
|
||||||
@ -94,7 +96,7 @@ monitor_free(MONITOR *mon)
|
|||||||
MONITOR *ptr;
|
MONITOR *ptr;
|
||||||
|
|
||||||
mon->module->stopMonitor(mon->handle);
|
mon->module->stopMonitor(mon->handle);
|
||||||
mon->state &= ~MONITOR_STATE_RUNNING;
|
mon->state = MONITOR_STATE_FREED;
|
||||||
spinlock_acquire(&monLock);
|
spinlock_acquire(&monLock);
|
||||||
if (allMonitors == mon)
|
if (allMonitors == mon)
|
||||||
allMonitors = mon->next;
|
allMonitors = mon->next;
|
||||||
@ -121,7 +123,7 @@ void
|
|||||||
monitorStart(MONITOR *monitor)
|
monitorStart(MONITOR *monitor)
|
||||||
{
|
{
|
||||||
monitor->handle = (*monitor->module->startMonitor)(monitor->handle);
|
monitor->handle = (*monitor->module->startMonitor)(monitor->handle);
|
||||||
monitor->state |= MONITOR_STATE_RUNNING;
|
monitor->state = MONITOR_STATE_RUNNING;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -132,8 +134,9 @@ monitorStart(MONITOR *monitor)
|
|||||||
void
|
void
|
||||||
monitorStop(MONITOR *monitor)
|
monitorStop(MONITOR *monitor)
|
||||||
{
|
{
|
||||||
|
monitor->state = MONITOR_STATE_STOPPING;
|
||||||
monitor->module->stopMonitor(monitor->handle);
|
monitor->module->stopMonitor(monitor->handle);
|
||||||
monitor->state &= ~MONITOR_STATE_RUNNING;
|
monitor->state = MONITOR_STATE_STOPPED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,6 +45,8 @@ extern int lm_enabled_logfiles_bitmask;
|
|||||||
* zombie management
|
* zombie management
|
||||||
* 29/08/14 Mark Riddoch Addition of thread status data, load average
|
* 29/08/14 Mark Riddoch Addition of thread status data, load average
|
||||||
* etc.
|
* etc.
|
||||||
|
* 23/09/14 Mark Riddoch Make use of RDHUP conditional to allow CentOS 5
|
||||||
|
* builds.
|
||||||
*
|
*
|
||||||
* @endverbatim
|
* @endverbatim
|
||||||
*/
|
*/
|
||||||
@ -192,7 +194,11 @@ poll_add_dcb(DCB *dcb)
|
|||||||
|
|
||||||
CHK_DCB(dcb);
|
CHK_DCB(dcb);
|
||||||
|
|
||||||
|
#ifdef EPOLLRDHUP
|
||||||
ev.events = EPOLLIN | EPOLLOUT | EPOLLRDHUP | EPOLLHUP | EPOLLET;
|
ev.events = EPOLLIN | EPOLLOUT | EPOLLRDHUP | EPOLLHUP | EPOLLET;
|
||||||
|
#else
|
||||||
|
ev.events = EPOLLIN | EPOLLOUT | EPOLLHUP | EPOLLET;
|
||||||
|
#endif
|
||||||
ev.data.ptr = dcb;
|
ev.data.ptr = dcb;
|
||||||
|
|
||||||
/*<
|
/*<
|
||||||
@ -631,6 +637,7 @@ DCB *zombies = NULL;
|
|||||||
spinlock_release(&dcb->dcb_initlock);
|
spinlock_release(&dcb->dcb_initlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef EPOLLRDHUP
|
||||||
if (ev & EPOLLRDHUP)
|
if (ev & EPOLLRDHUP)
|
||||||
{
|
{
|
||||||
int eno = 0;
|
int eno = 0;
|
||||||
@ -657,9 +664,10 @@ DCB *zombies = NULL;
|
|||||||
else
|
else
|
||||||
spinlock_release(&dcb->dcb_initlock);
|
spinlock_release(&dcb->dcb_initlock);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
} /*< for */
|
} /*< for */
|
||||||
no_op = FALSE;
|
no_op = FALSE;
|
||||||
}
|
} /*< if (nfds > 0) */
|
||||||
process_zombies:
|
process_zombies:
|
||||||
if (thread_data)
|
if (thread_data)
|
||||||
{
|
{
|
||||||
@ -682,6 +690,8 @@ process_zombies:
|
|||||||
thread_data[thread_id].state = THREAD_STOPPED;
|
thread_data[thread_id].state = THREAD_STOPPED;
|
||||||
}
|
}
|
||||||
bitmask_clear(&poll_mask, thread_id);
|
bitmask_clear(&poll_mask, thread_id);
|
||||||
|
/** Release mysql thread context */
|
||||||
|
mysql_thread_end();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (thread_data)
|
if (thread_data)
|
||||||
@ -689,8 +699,6 @@ process_zombies:
|
|||||||
thread_data[thread_id].state = THREAD_IDLE;
|
thread_data[thread_id].state = THREAD_IDLE;
|
||||||
}
|
}
|
||||||
} /*< while(1) */
|
} /*< while(1) */
|
||||||
/** Release mysql thread context */
|
|
||||||
mysql_thread_end();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -785,12 +793,14 @@ char *str;
|
|||||||
strcat(str, "|");
|
strcat(str, "|");
|
||||||
strcat(str, "HUP");
|
strcat(str, "HUP");
|
||||||
}
|
}
|
||||||
|
#ifdef EPOLLRDHUP
|
||||||
if (event & EPOLLRDHUP)
|
if (event & EPOLLRDHUP)
|
||||||
{
|
{
|
||||||
if (*str)
|
if (*str)
|
||||||
strcat(str, "|");
|
strcat(str, "|");
|
||||||
strcat(str, "RDHUP");
|
strcat(str, "RDHUP");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ typedef struct {
|
|||||||
void (*unregisterServer)(void *, SERVER *);
|
void (*unregisterServer)(void *, SERVER *);
|
||||||
void (*defaultUser)(void *, char *, char *);
|
void (*defaultUser)(void *, char *, char *);
|
||||||
void (*diagnostics)(DCB *, void *);
|
void (*diagnostics)(DCB *, void *);
|
||||||
void (*setInterval)(void *, unsigned long);
|
void (*setInterval)(void *, size_t);
|
||||||
void (*defaultId)(void *, unsigned long);
|
void (*defaultId)(void *, unsigned long);
|
||||||
void (*replicationHeartbeat)(void *, int);
|
void (*replicationHeartbeat)(void *, int);
|
||||||
void (*detectStaleMaster)(void *, int);
|
void (*detectStaleMaster)(void *, int);
|
||||||
@ -81,21 +81,30 @@ typedef struct {
|
|||||||
*/
|
*/
|
||||||
#define MONITOR_VERSION {1, 0, 0}
|
#define MONITOR_VERSION {1, 0, 0}
|
||||||
|
|
||||||
|
/** Monitor's poll frequency */
|
||||||
|
#define MON_BASE_INTERVAL_MS 100
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Monitor state bit mask values
|
* Monitor state bit mask values
|
||||||
*/
|
*/
|
||||||
#define MONITOR_STATE_RUNNING 0x0001
|
typedef enum
|
||||||
|
{
|
||||||
|
MONITOR_STATE_ALLOC = 0x00,
|
||||||
|
MONITOR_STATE_RUNNING = 0x01,
|
||||||
|
MONITOR_STATE_STOPPING = 0x02,
|
||||||
|
MONITOR_STATE_STOPPED = 0x04,
|
||||||
|
MONITOR_STATE_FREED = 0x08
|
||||||
|
} monitor_state_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Representation of the running monitor.
|
* Representation of the running monitor.
|
||||||
*/
|
*/
|
||||||
typedef struct monitor {
|
typedef struct monitor {
|
||||||
char *name; /**< The name of the monitor module */
|
char *name; /**< The name of the monitor module */
|
||||||
unsigned int state; /**< The monitor status */
|
monitor_state_t state; /**< The state of the monitor */
|
||||||
MONITOR_OBJECT *module; /**< The "monitor object" */
|
MONITOR_OBJECT *module; /**< The "monitor object" */
|
||||||
void *handle; /**< Handle returned from startMonitor */
|
void *handle; /**< Handle returned from startMonitor */
|
||||||
int interval; /**< The monitor interval */
|
size_t interval; /**< The monitor interval */
|
||||||
struct monitor *next; /**< Next monitor in the linked list */
|
struct monitor *next; /**< Next monitor in the linked list */
|
||||||
} MONITOR;
|
} MONITOR;
|
||||||
|
|
||||||
|
@ -67,9 +67,20 @@ static void registerServer(void *, SERVER *);
|
|||||||
static void unregisterServer(void *, SERVER *);
|
static void unregisterServer(void *, SERVER *);
|
||||||
static void defaultUsers(void *, char *, char *);
|
static void defaultUsers(void *, char *, char *);
|
||||||
static void diagnostics(DCB *, void *);
|
static void diagnostics(DCB *, void *);
|
||||||
static void setInterval(void *, unsigned long);
|
static void setInterval(void *, size_t);
|
||||||
|
|
||||||
static MONITOR_OBJECT MyObject = { startMonitor, stopMonitor, registerServer, unregisterServer, defaultUsers, diagnostics, setInterval, NULL, NULL, NULL };
|
static MONITOR_OBJECT MyObject = {
|
||||||
|
startMonitor,
|
||||||
|
stopMonitor,
|
||||||
|
registerServer,
|
||||||
|
unregisterServer,
|
||||||
|
defaultUsers,
|
||||||
|
diagnostics,
|
||||||
|
setInterval,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of the mandatory version entry point
|
* Implementation of the mandatory version entry point
|
||||||
@ -413,6 +424,7 @@ monitorMain(void *arg)
|
|||||||
MYSQL_MONITOR *handle = (MYSQL_MONITOR *)arg;
|
MYSQL_MONITOR *handle = (MYSQL_MONITOR *)arg;
|
||||||
MONITOR_SERVERS *ptr;
|
MONITOR_SERVERS *ptr;
|
||||||
long master_id;
|
long master_id;
|
||||||
|
size_t nrounds = 0;
|
||||||
|
|
||||||
if (mysql_thread_init())
|
if (mysql_thread_init())
|
||||||
{
|
{
|
||||||
@ -423,10 +435,9 @@ long master_id;
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
handle->status = MONITOR_RUNNING;
|
handle->status = MONITOR_RUNNING;
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
master_id = -1;
|
|
||||||
|
|
||||||
if (handle->shutdown)
|
if (handle->shutdown)
|
||||||
{
|
{
|
||||||
handle->status = MONITOR_STOPPING;
|
handle->status = MONITOR_STOPPING;
|
||||||
@ -434,7 +445,16 @@ long master_id;
|
|||||||
handle->status = MONITOR_STOPPED;
|
handle->status = MONITOR_STOPPED;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
/** Wait base interval */
|
||||||
|
thread_millisleep(MON_BASE_INTERVAL_MS);
|
||||||
|
nrounds += 1;
|
||||||
|
|
||||||
|
/** If monitor interval time isn't consumed skip checks */
|
||||||
|
if ((nrounds*MON_BASE_INTERVAL_MS)%handle->interval != 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
master_id = -1;
|
||||||
ptr = handle->databases;
|
ptr = handle->databases;
|
||||||
|
|
||||||
while (ptr)
|
while (ptr)
|
||||||
@ -491,7 +511,6 @@ long master_id;
|
|||||||
|
|
||||||
ptr = ptr->next;
|
ptr = ptr->next;
|
||||||
}
|
}
|
||||||
thread_millisleep(handle->interval);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -502,7 +521,7 @@ long master_id;
|
|||||||
* @param interval The interval to set in monitor struct, in milliseconds
|
* @param interval The interval to set in monitor struct, in milliseconds
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
setInterval(void *arg, unsigned long interval)
|
setInterval(void *arg, size_t interval)
|
||||||
{
|
{
|
||||||
MYSQL_MONITOR *handle = (MYSQL_MONITOR *)arg;
|
MYSQL_MONITOR *handle = (MYSQL_MONITOR *)arg;
|
||||||
memcpy(&handle->interval, &interval, sizeof(unsigned long));
|
memcpy(&handle->interval, &interval, sizeof(unsigned long));
|
||||||
|
@ -80,7 +80,7 @@ static void registerServer(void *, SERVER *);
|
|||||||
static void unregisterServer(void *, SERVER *);
|
static void unregisterServer(void *, SERVER *);
|
||||||
static void defaultUser(void *, char *, char *);
|
static void defaultUser(void *, char *, char *);
|
||||||
static void diagnostics(DCB *, void *);
|
static void diagnostics(DCB *, void *);
|
||||||
static void setInterval(void *, unsigned long);
|
static void setInterval(void *, size_t);
|
||||||
static void defaultId(void *, unsigned long);
|
static void defaultId(void *, unsigned long);
|
||||||
static void replicationHeartbeat(void *, int);
|
static void replicationHeartbeat(void *, int);
|
||||||
static void detectStaleMaster(void *, int);
|
static void detectStaleMaster(void *, int);
|
||||||
@ -95,7 +95,18 @@ static int add_slave_to_master(long *, int, long);
|
|||||||
static void monitor_set_pending_status(MONITOR_SERVERS *, int);
|
static void monitor_set_pending_status(MONITOR_SERVERS *, int);
|
||||||
static void monitor_clear_pending_status(MONITOR_SERVERS *, int);
|
static void monitor_clear_pending_status(MONITOR_SERVERS *, int);
|
||||||
|
|
||||||
static MONITOR_OBJECT MyObject = { startMonitor, stopMonitor, registerServer, unregisterServer, defaultUser, diagnostics, setInterval, defaultId, replicationHeartbeat, detectStaleMaster };
|
static MONITOR_OBJECT MyObject = {
|
||||||
|
startMonitor,
|
||||||
|
stopMonitor,
|
||||||
|
registerServer,
|
||||||
|
unregisterServer,
|
||||||
|
defaultUser,
|
||||||
|
diagnostics,
|
||||||
|
setInterval,
|
||||||
|
defaultId,
|
||||||
|
replicationHeartbeat,
|
||||||
|
detectStaleMaster
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of the mandatory version entry point
|
* Implementation of the mandatory version entry point
|
||||||
@ -577,6 +588,7 @@ int replication_heartbeat = handle->replicationHeartbeat;
|
|||||||
int detect_stale_master = handle->detectStaleMaster;
|
int detect_stale_master = handle->detectStaleMaster;
|
||||||
int num_servers=0;
|
int num_servers=0;
|
||||||
MONITOR_SERVERS *root_master;
|
MONITOR_SERVERS *root_master;
|
||||||
|
size_t nrounds = 0;
|
||||||
|
|
||||||
if (mysql_thread_init())
|
if (mysql_thread_init())
|
||||||
{
|
{
|
||||||
@ -586,8 +598,8 @@ MONITOR_SERVERS *root_master;
|
|||||||
"module. Exiting.\n")));
|
"module. Exiting.\n")));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
handle->status = MONITOR_RUNNING;
|
handle->status = MONITOR_RUNNING;
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
if (handle->shutdown)
|
if (handle->shutdown)
|
||||||
@ -597,6 +609,15 @@ MONITOR_SERVERS *root_master;
|
|||||||
handle->status = MONITOR_STOPPED;
|
handle->status = MONITOR_STOPPED;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
/** Wait base interval */
|
||||||
|
thread_millisleep(MON_BASE_INTERVAL_MS);
|
||||||
|
nrounds += 1;
|
||||||
|
|
||||||
|
/** If monitor interval time isn't consumed skip checks */
|
||||||
|
if ((nrounds*MON_BASE_INTERVAL_MS)%handle->interval != 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
/* reset num_servers */
|
/* reset num_servers */
|
||||||
num_servers = 0;
|
num_servers = 0;
|
||||||
|
|
||||||
@ -686,10 +707,7 @@ MONITOR_SERVERS *root_master;
|
|||||||
ptr = ptr->next;
|
ptr = ptr->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} /*< while (1) */
|
||||||
/* wait for the configured interval */
|
|
||||||
thread_millisleep(handle->interval);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -712,7 +730,7 @@ MYSQL_MONITOR *handle = (MYSQL_MONITOR *)arg;
|
|||||||
* @param interval The interval to set in monitor struct, in milliseconds
|
* @param interval The interval to set in monitor struct, in milliseconds
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
setInterval(void *arg, unsigned long interval)
|
setInterval(void *arg, size_t interval)
|
||||||
{
|
{
|
||||||
MYSQL_MONITOR *handle = (MYSQL_MONITOR *)arg;
|
MYSQL_MONITOR *handle = (MYSQL_MONITOR *)arg;
|
||||||
memcpy(&handle->interval, &interval, sizeof(unsigned long));
|
memcpy(&handle->interval, &interval, sizeof(unsigned long));
|
||||||
|
@ -61,9 +61,20 @@ static void registerServer(void *, SERVER *);
|
|||||||
static void unregisterServer(void *, SERVER *);
|
static void unregisterServer(void *, SERVER *);
|
||||||
static void defaultUsers(void *, char *, char *);
|
static void defaultUsers(void *, char *, char *);
|
||||||
static void diagnostics(DCB *, void *);
|
static void diagnostics(DCB *, void *);
|
||||||
static void setInterval(void *, unsigned long);
|
static void setInterval(void *, size_t);
|
||||||
|
|
||||||
static MONITOR_OBJECT MyObject = { startMonitor, stopMonitor, registerServer, unregisterServer, defaultUsers, diagnostics, setInterval, NULL, NULL, NULL };
|
static MONITOR_OBJECT MyObject = {
|
||||||
|
startMonitor,
|
||||||
|
stopMonitor,
|
||||||
|
registerServer,
|
||||||
|
unregisterServer,
|
||||||
|
defaultUsers,
|
||||||
|
diagnostics,
|
||||||
|
setInterval,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of the mandatory version entry point
|
* Implementation of the mandatory version entry point
|
||||||
@ -410,6 +421,7 @@ monitorMain(void *arg)
|
|||||||
MYSQL_MONITOR *handle = (MYSQL_MONITOR *)arg;
|
MYSQL_MONITOR *handle = (MYSQL_MONITOR *)arg;
|
||||||
MONITOR_SERVERS *ptr;
|
MONITOR_SERVERS *ptr;
|
||||||
long master_id;
|
long master_id;
|
||||||
|
size_t nrounds = 0;
|
||||||
|
|
||||||
if (mysql_thread_init())
|
if (mysql_thread_init())
|
||||||
{
|
{
|
||||||
@ -420,10 +432,9 @@ long master_id;
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
handle->status = MONITOR_RUNNING;
|
handle->status = MONITOR_RUNNING;
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
master_id = -1;
|
|
||||||
|
|
||||||
if (handle->shutdown)
|
if (handle->shutdown)
|
||||||
{
|
{
|
||||||
handle->status = MONITOR_STOPPING;
|
handle->status = MONITOR_STOPPING;
|
||||||
@ -432,6 +443,16 @@ long master_id;
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Wait base interval */
|
||||||
|
thread_millisleep(MON_BASE_INTERVAL_MS);
|
||||||
|
nrounds += 1;
|
||||||
|
|
||||||
|
/** If monitor interval time isn't consumed skip checks */
|
||||||
|
if ((nrounds*MON_BASE_INTERVAL_MS)%handle->interval != 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
master_id = -1;
|
||||||
ptr = handle->databases;
|
ptr = handle->databases;
|
||||||
|
|
||||||
while (ptr)
|
while (ptr)
|
||||||
@ -452,8 +473,6 @@ long master_id;
|
|||||||
|
|
||||||
ptr = ptr->next;
|
ptr = ptr->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
thread_millisleep(handle->interval);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -464,7 +483,7 @@ long master_id;
|
|||||||
* @param interval The interval to set in monitor struct, in milliseconds
|
* @param interval The interval to set in monitor struct, in milliseconds
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
setInterval(void *arg, unsigned long interval)
|
setInterval(void *arg, size_t interval)
|
||||||
{
|
{
|
||||||
MYSQL_MONITOR *handle = (MYSQL_MONITOR *)arg;
|
MYSQL_MONITOR *handle = (MYSQL_MONITOR *)arg;
|
||||||
memcpy(&handle->interval, &interval, sizeof(unsigned long));
|
memcpy(&handle->interval, &interval, sizeof(unsigned long));
|
||||||
|
Reference in New Issue
Block a user