Reindent server/core/monitor.c
This commit is contained in:
@ -122,15 +122,21 @@ MONITOR *ptr;
|
||||
mon->state = MONITOR_STATE_FREED;
|
||||
spinlock_acquire(&monLock);
|
||||
if (allMonitors == mon)
|
||||
{
|
||||
allMonitors = mon->next;
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr = allMonitors;
|
||||
while (ptr->next && ptr->next != mon)
|
||||
{
|
||||
ptr = ptr->next;
|
||||
}
|
||||
if (ptr->next)
|
||||
{
|
||||
ptr->next = mon->next;
|
||||
}
|
||||
}
|
||||
spinlock_release(&monLock);
|
||||
free_config_parameter(mon->parameters);
|
||||
free(mon->name);
|
||||
@ -216,7 +222,9 @@ monitorAddServer(MONITOR *mon, SERVER *server)
|
||||
MONITOR_SERVERS *ptr, *db;
|
||||
|
||||
if ((db = (MONITOR_SERVERS *)malloc(sizeof(MONITOR_SERVERS))) == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
db->server = server;
|
||||
db->con = NULL;
|
||||
db->next = NULL;
|
||||
@ -230,12 +238,16 @@ monitorAddServer(MONITOR *mon, SERVER *server)
|
||||
spinlock_acquire(&mon->lock);
|
||||
|
||||
if (mon->databases == NULL)
|
||||
{
|
||||
mon->databases = db;
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr = mon->databases;
|
||||
while (ptr->next != NULL)
|
||||
{
|
||||
ptr = ptr->next;
|
||||
}
|
||||
ptr->next = db;
|
||||
}
|
||||
spinlock_release(&mon->lock);
|
||||
@ -273,7 +285,9 @@ MONITOR *ptr;
|
||||
dcb_printf(dcb, "Monitor: %p\n", ptr);
|
||||
dcb_printf(dcb, "\tName: %s\n", ptr->name);
|
||||
if (ptr->module->diagnostics)
|
||||
{
|
||||
ptr->module->diagnostics(dcb, ptr);
|
||||
}
|
||||
ptr = ptr->next;
|
||||
}
|
||||
spinlock_release(&monLock);
|
||||
@ -291,8 +305,10 @@ monitorShow(DCB *dcb, MONITOR *monitor)
|
||||
dcb_printf(dcb, "Monitor: %p\n", monitor);
|
||||
dcb_printf(dcb, "\tName: %s\n", monitor->name);
|
||||
if (monitor->module->diagnostics)
|
||||
{
|
||||
monitor->module->diagnostics(dcb, monitor);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* List all the monitors
|
||||
@ -336,7 +352,9 @@ MONITOR *ptr;
|
||||
while (ptr)
|
||||
{
|
||||
if (!strcmp(ptr->name, name))
|
||||
{
|
||||
break;
|
||||
}
|
||||
ptr = ptr->next;
|
||||
}
|
||||
spinlock_release(&monLock);
|
||||
@ -369,13 +387,18 @@ monitorSetNetworkTimeout(MONITOR *mon, int type, int value) {
|
||||
int new_timeout = max_timeout -1;
|
||||
|
||||
if (new_timeout <= 0)
|
||||
{
|
||||
new_timeout = DEFAULT_CONNECT_TIMEOUT;
|
||||
}
|
||||
|
||||
switch(type) {
|
||||
case MONITOR_CONNECT_TIMEOUT:
|
||||
if (value < max_timeout) {
|
||||
if (value < max_timeout)
|
||||
{
|
||||
memcpy(&mon->connect_timeout, &value, sizeof(int));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(&mon->connect_timeout, &new_timeout, sizeof(int));
|
||||
MXS_WARNING("Monitor Connect Timeout %i is greater than monitor interval ~%i seconds"
|
||||
", lowering to %i seconds", value, max_timeout, new_timeout);
|
||||
@ -383,9 +406,12 @@ monitorSetNetworkTimeout(MONITOR *mon, int type, int value) {
|
||||
break;
|
||||
|
||||
case MONITOR_READ_TIMEOUT:
|
||||
if (value < max_timeout) {
|
||||
if (value < max_timeout)
|
||||
{
|
||||
memcpy(&mon->read_timeout, &value, sizeof(int));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(&mon->read_timeout, &new_timeout, sizeof(int));
|
||||
MXS_WARNING("Monitor Read Timeout %i is greater than monitor interval ~%i seconds"
|
||||
", lowering to %i seconds", value, max_timeout, new_timeout);
|
||||
@ -393,9 +419,12 @@ monitorSetNetworkTimeout(MONITOR *mon, int type, int value) {
|
||||
break;
|
||||
|
||||
case MONITOR_WRITE_TIMEOUT:
|
||||
if (value < max_timeout) {
|
||||
if (value < max_timeout)
|
||||
{
|
||||
memcpy(&mon->write_timeout, &value, sizeof(int));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(&mon->write_timeout, &new_timeout, sizeof(int));
|
||||
MXS_WARNING("Monitor Write Timeout %i is greater than monitor interval ~%i seconds"
|
||||
", lowering to %i seconds", value, max_timeout, new_timeout);
|
||||
@ -457,7 +486,9 @@ RESULTSET *set;
|
||||
int *data;
|
||||
|
||||
if ((data = (int *)malloc(sizeof(int))) == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
*data = 0;
|
||||
if ((set = resultset_create(monitorRowCallback, data)) == NULL)
|
||||
{
|
||||
@ -600,13 +631,15 @@ monitor_clear_pending_status(MONITOR_SERVERS *ptr, int bit)
|
||||
monitor_event_t
|
||||
mon_get_event_type(MONITOR_SERVERS* node)
|
||||
{
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
DOWN_EVENT,
|
||||
UP_EVENT,
|
||||
LOSS_EVENT,
|
||||
NEW_EVENT,
|
||||
UNSUPPORTED_EVENT
|
||||
} general_event_type;
|
||||
|
||||
general_event_type event_type = UNSUPPORTED_EVENT;
|
||||
|
||||
unsigned int prev = node->mon_prev_status
|
||||
|
||||
@ -73,7 +73,8 @@
|
||||
* unregisterServer is called to remove a server from the set of servers that need to be
|
||||
* monitored.
|
||||
*/
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
void *(*startMonitor)(void *, void*);
|
||||
void (*stopMonitor)(void *);
|
||||
void (*diagnostics)(DCB *, void *);
|
||||
@ -158,21 +159,22 @@ extern const monitor_def_t monitor_event_definitions[];
|
||||
/**
|
||||
* The linked list of servers that are being monitored by the monitor module.
|
||||
*/
|
||||
typedef struct monitor_servers {
|
||||
typedef struct monitor_servers
|
||||
{
|
||||
SERVER *server; /**< The server being monitored */
|
||||
MYSQL *con; /**< The MySQL connection */
|
||||
bool log_version_err;
|
||||
int mon_err_count;
|
||||
unsigned int mon_prev_status;
|
||||
unsigned int pending_status; /**< Pending Status flag bitmap */
|
||||
struct monitor_servers
|
||||
*next; /**< The next server in the list */
|
||||
struct monitor_servers *next; /**< The next server in the list */
|
||||
} MONITOR_SERVERS;
|
||||
|
||||
/**
|
||||
* Representation of the running monitor.
|
||||
*/
|
||||
typedef struct monitor {
|
||||
typedef struct monitor
|
||||
{
|
||||
char *name; /**< The name of the monitor module */
|
||||
char *user; /*< Monitor username */
|
||||
char *password; /*< Monitor password */
|
||||
@ -182,10 +184,12 @@ typedef struct monitor {
|
||||
monitor_state_t state; /**< The state of the monitor */
|
||||
int connect_timeout; /**< Connect timeout in seconds for mysql_real_connect */
|
||||
int read_timeout; /**< Timeout in seconds to read from the server.
|
||||
* There are retries and the total effective timeout value is three times the option value.
|
||||
* There are retries and the total effective timeout
|
||||
* value is three times the option value.
|
||||
*/
|
||||
int write_timeout; /**< Timeout in seconds for each attempt to write to the server.
|
||||
* There are retries and the total effective timeout value is two times the option value.
|
||||
* There are retries and the total effective timeout value is
|
||||
* two times the option value.
|
||||
*/
|
||||
MONITOR_OBJECT *module; /**< The "monitor object" */
|
||||
void *handle; /**< Handle returned from startMonitor */
|
||||
|
||||
Reference in New Issue
Block a user