Master/Slave detection based on variable only

Master/Slave role setting is now based on variable value only.

Replication is checked and, if working, master_id, slave_id are saved
into server struct
This commit is contained in:
MassimilianoPinto
2015-04-29 10:50:21 +02:00
parent 8bff81e0a9
commit 1755706ada

View File

@ -531,18 +531,20 @@ char *server_string;
} }
/* get variable 'read_only' set by an external component */ /* get variable 'read_only' set by an external component */
if (mysql_query(database->con, "SHOW GLOBAL VARIABLES LIKE 'read_only'") == 0 if (mysql_query(database->con, "SHOW GLOBAL VARIABLES LIKE 'read_only'") == 0
&& (result = mysql_store_result(database->con)) != NULL) && (result = mysql_store_result(database->con)) != NULL)
{ {
num_fields = mysql_num_fields(result); num_fields = mysql_num_fields(result);
while ((row = mysql_fetch_row(result))) while ((row = mysql_fetch_row(result)))
{ {
if (strncasecmp(row[1], "OFF", 3) == 0) { if (strncasecmp(row[1], "OFF", 3) == 0) {
ismaster = 1; ismaster = 1;
} } else {
} isslave = 1;
mysql_free_result(result); }
} }
mysql_free_result(result);
}
/* Remove addition info */ /* Remove addition info */
monitor_clear_pending_status(database, SERVER_STALE_STATUS); monitor_clear_pending_status(database, SERVER_STALE_STATUS);
@ -563,7 +565,7 @@ char *server_string;
} }
/* Set the Master role */ /* Set the Master role */
if (isslave && ismaster) if (ismaster)
{ {
monitor_clear_pending_status(database, SERVER_SLAVE); monitor_clear_pending_status(database, SERVER_SLAVE);
monitor_set_pending_status(database, SERVER_MASTER); monitor_set_pending_status(database, SERVER_MASTER);