diff --git a/server/modules/monitor/CMakeLists.txt b/server/modules/monitor/CMakeLists.txt index 9c86696b2..ad5c2e47e 100644 --- a/server/modules/monitor/CMakeLists.txt +++ b/server/modules/monitor/CMakeLists.txt @@ -1,6 +1,6 @@ -add_subdirectory(galeramon) -add_subdirectory(mmmon) -add_subdirectory(mariadbmon) -add_subdirectory(ndbclustermon) add_subdirectory(auroramon) +add_subdirectory(galeramon) add_subdirectory(grmon) +add_subdirectory(mariadbmon) +add_subdirectory(mmmon) +add_subdirectory(ndbclustermon) diff --git a/server/modules/monitor/auroramon/CMakeLists.txt b/server/modules/monitor/auroramon/CMakeLists.txt index ee3269d2d..0b47d833c 100644 --- a/server/modules/monitor/auroramon/CMakeLists.txt +++ b/server/modules/monitor/auroramon/CMakeLists.txt @@ -1,4 +1,4 @@ -add_library(auroramon SHARED auroramon.c) +add_library(auroramon SHARED auroramon.cc) target_link_libraries(auroramon maxscale-common) add_dependencies(auroramon pcre2) set_target_properties(auroramon PROPERTIES VERSION "1.0.0") diff --git a/server/modules/monitor/auroramon/auroramon.c b/server/modules/monitor/auroramon/auroramon.cc similarity index 97% rename from server/modules/monitor/auroramon/auroramon.c rename to server/modules/monitor/auroramon/auroramon.cc index 6e2da9708..b6ae7591e 100644 --- a/server/modules/monitor/auroramon/auroramon.c +++ b/server/modules/monitor/auroramon/auroramon.cc @@ -48,7 +48,8 @@ void update_server_status(MXS_MONITOR *monitor, MXS_MONITORED_SERVER *database) { if (!SERVER_IN_MAINT(database->server)) { - SERVER temp_server = {.status = database->server->status}; + SERVER temp_server = {}; + temp_server.status = database->server->status; server_clear_status_nolock(&temp_server, SERVER_RUNNING | SERVER_MASTER | SERVER_SLAVE | SERVER_AUTH_ERROR); database->mon_prev_status = database->server->status; @@ -148,7 +149,7 @@ monitorMain(void *arg) release_monitor_servers(monitor); /** Sleep until the next monitoring interval */ - int ms = 0; + unsigned int ms = 0; while (ms < monitor->interval && !handle->shutdown) { if (monitor->server_pending_changes) @@ -188,7 +189,7 @@ static void auroramon_free(AURORA_MONITOR *handle) static void * startMonitor(MXS_MONITOR *mon, const MXS_CONFIG_PARAMETER *params) { - AURORA_MONITOR *handle = mon->handle; + AURORA_MONITOR *handle = static_cast(mon->handle); if (handle) { @@ -264,6 +265,8 @@ static json_t* diagnostics_json(const MXS_MONITOR *mon) return NULL; } +extern "C" +{ /** * The module entry point routine. It is this routine that must populate the * structure that is referred to as the "module object", this is a structure @@ -314,3 +317,5 @@ MXS_MODULE* MXS_CREATE_MODULE() return &info; } + +} diff --git a/server/modules/monitor/galeramon/CMakeLists.txt b/server/modules/monitor/galeramon/CMakeLists.txt index 8ee1cb289..fe2ada2fd 100644 --- a/server/modules/monitor/galeramon/CMakeLists.txt +++ b/server/modules/monitor/galeramon/CMakeLists.txt @@ -1,4 +1,4 @@ -add_library(galeramon SHARED galeramon.c) +add_library(galeramon SHARED galeramon.cc) target_link_libraries(galeramon maxscale-common) add_dependencies(galeramon pcre2) set_target_properties(galeramon PROPERTIES VERSION "2.0.0") diff --git a/server/modules/monitor/galeramon/galeramon.c b/server/modules/monitor/galeramon/galeramon.cc similarity index 96% rename from server/modules/monitor/galeramon/galeramon.c rename to server/modules/monitor/galeramon/galeramon.cc index 504e9eedd..aaa14cafa 100644 --- a/server/modules/monitor/galeramon/galeramon.c +++ b/server/modules/monitor/galeramon/galeramon.cc @@ -48,6 +48,8 @@ static void set_galera_cluster(MXS_MONITOR *); static bool detect_cluster_size(const GALERA_MONITOR *, const int, const char *, const int); static void set_cluster_members(MXS_MONITOR *); +extern "C" +{ /** * The module entry point routine. It is this routine that * must populate the structure that is referred to as the @@ -108,6 +110,8 @@ MXS_MODULE* MXS_CREATE_MODULE() return &info; } +} + /** * Start the instance of the monitor, returning a handle on the monitor. * @@ -118,7 +122,7 @@ MXS_MODULE* MXS_CREATE_MODULE() static void * startMonitor(MXS_MONITOR *mon, const MXS_CONFIG_PARAMETER *params) { - GALERA_MONITOR *handle = mon->handle; + GALERA_MONITOR *handle = static_cast(mon->handle); if (handle != NULL) { handle->shutdown = 0; @@ -352,11 +356,12 @@ monitorDatabase(MXS_MONITOR *mon, MXS_MONITORED_SERVER *database) server_string = database->server->version_string; /* Check if the the Galera FSM shows this node is joined to the cluster */ - char *cluster_member = "SHOW STATUS WHERE Variable_name IN" - " ('wsrep_cluster_state_uuid'," - " 'wsrep_cluster_size'," - " 'wsrep_local_index'," - " 'wsrep_local_state')"; + const char *cluster_member = + "SHOW STATUS WHERE Variable_name IN" + " ('wsrep_cluster_state_uuid'," + " 'wsrep_cluster_size'," + " 'wsrep_local_index'," + " 'wsrep_local_state')"; if (mxs_mysql_query(database->con, cluster_member) == 0 && (result = mysql_store_result(database->con)) != NULL) @@ -449,7 +454,8 @@ monitorDatabase(MXS_MONITOR *mon, MXS_MONITORED_SERVER *database) /* Galera Cluster vars fetch */ HASHTABLE *table = handle->galera_nodes_info; - GALERA_NODE_INFO *node = hashtable_fetch(table, database->server->name); + GALERA_NODE_INFO *node = + static_cast(hashtable_fetch(table, database->server->name)); if (node) { MXS_DEBUG("Node %s is present in galera_nodes_info, updtating info", @@ -683,7 +689,7 @@ static MXS_MONITORED_SERVER *get_candidate_master(MXS_MONITOR* mon) { MXS_MONITORED_SERVER *moitor_servers = mon->monitored_servers; MXS_MONITORED_SERVER *candidate_master = NULL; - GALERA_MONITOR* handle = mon->handle; + GALERA_MONITOR* handle = static_cast(mon->handle); long min_id = -1; int minval = INT_MAX; int currval; @@ -807,7 +813,7 @@ static void update_sst_donor_nodes(MXS_MONITOR *mon, int is_cluster) MXS_MONITORED_SERVER *ptr; MYSQL_ROW row; MYSQL_RES *result; - GALERA_MONITOR *handle = mon->handle; + GALERA_MONITOR *handle = static_cast(mon->handle); bool ignore_priority = true; if (is_cluster == 1) @@ -820,9 +826,9 @@ static void update_sst_donor_nodes(MXS_MONITOR *mon, int is_cluster) MXS_MONITORED_SERVER *node_list[is_cluster - 1]; /* Donor list size = DONOR_LIST_SET_VAR + n_hosts * max_host_len + n_hosts + 1 */ - char *donor_list = MXS_CALLOC(1, strlen(DONOR_LIST_SET_VAR) + - is_cluster * DONOR_NODE_NAME_MAX_LEN + - is_cluster + 1); + char *donor_list = static_cast(MXS_CALLOC(1, strlen(DONOR_LIST_SET_VAR) + + is_cluster * DONOR_NODE_NAME_MAX_LEN + + is_cluster + 1)); if (donor_list == NULL) { @@ -871,7 +877,7 @@ static void update_sst_donor_nodes(MXS_MONITOR *mon, int is_cluster) sort_order ? compare_node_priority : compare_node_index); /* Select nodename from each server and append it to node_list */ - for (int k = 0; k < found_slaves; k++) + for (unsigned int k = 0; k < found_slaves; k++) { MXS_MONITORED_SERVER *ptr = node_list[k]; @@ -917,7 +923,7 @@ static void update_sst_donor_nodes(MXS_MONITOR *mon, int is_cluster) donor_list); /* Set now rep_sst_donor in each slave node */ - for (int k = 0; k < found_slaves; k++) + for (unsigned int k = 0; k < found_slaves; k++) { MXS_MONITORED_SERVER *ptr = node_list[k]; /* Set the Galera SST donor node list */ @@ -1092,7 +1098,7 @@ static GALERA_NODE_INFO *nodeval_dup(const GALERA_NODE_INFO *in) rval->node = in->node; rval->joined = in->joined; - return (void *) rval; + return rval; } /** @@ -1119,7 +1125,7 @@ static void nodeval_free(GALERA_NODE_INFO *in) */ static void set_galera_cluster(MXS_MONITOR *mon) { - GALERA_MONITOR *handle = mon->handle; + GALERA_MONITOR *handle = static_cast(mon->handle); int ret = false; int n_nodes = 0; HASHITERATOR *iterator; @@ -1133,10 +1139,10 @@ static void set_galera_cluster(MXS_MONITOR *mon) if ((iterator = hashtable_iterator(table)) != NULL) { /* Get the Key */ - while ((key = hashtable_next(iterator)) != NULL) + while ((key = static_cast(hashtable_next(iterator))) != NULL) { /* fetch the Value for the Key */ - value = hashtable_fetch(table, key); + value = static_cast(hashtable_fetch(table, key)); if (value) { if (!SERVER_IN_MAINT(value->node) && @@ -1206,7 +1212,7 @@ static void set_galera_cluster(MXS_MONITOR *mon) */ static void set_cluster_members(MXS_MONITOR *mon) { - GALERA_MONITOR *handle = mon->handle; + GALERA_MONITOR *handle = static_cast(mon->handle); GALERA_NODE_INFO *value; MXS_MONITORED_SERVER *ptr; char *c_uuid = handle->cluster_info.c_uuid; @@ -1216,7 +1222,8 @@ static void set_cluster_members(MXS_MONITOR *mon) while (ptr) { /* Fetch cluster info for this server, if any */ - value = hashtable_fetch(handle->galera_nodes_info, ptr->server->name); + value = static_cast(hashtable_fetch(handle->galera_nodes_info, + ptr->server->name)); if (value && handle->cluster_info.c_uuid) { @@ -1291,7 +1298,7 @@ static bool detect_cluster_size(const GALERA_MONITOR *handle, } else if (n_nodes == 1) { - char *msg = "Galera cluster with 1 node only"; + const char *msg = "Galera cluster with 1 node only"; /* If 1 node only: * ifc_uuid is not set, return value will be true. diff --git a/server/modules/monitor/mmmon/CMakeLists.txt b/server/modules/monitor/mmmon/CMakeLists.txt index 2be5171bd..a50cd99c6 100644 --- a/server/modules/monitor/mmmon/CMakeLists.txt +++ b/server/modules/monitor/mmmon/CMakeLists.txt @@ -1,4 +1,4 @@ -add_library(mmmon SHARED mmmon.c) +add_library(mmmon SHARED mmmon.cc) target_link_libraries(mmmon maxscale-common) add_dependencies(mmmon pcre2) set_target_properties(mmmon PROPERTIES VERSION "1.1.1") diff --git a/server/modules/monitor/mmmon/mmmon.c b/server/modules/monitor/mmmon/mmmon.cc similarity index 99% rename from server/modules/monitor/mmmon/mmmon.c rename to server/modules/monitor/mmmon/mmmon.cc index de78e851f..88538b1dd 100644 --- a/server/modules/monitor/mmmon/mmmon.c +++ b/server/modules/monitor/mmmon/mmmon.cc @@ -46,6 +46,8 @@ static void detectStaleMaster(void *, int); static MXS_MONITORED_SERVER *get_current_master(MXS_MONITOR *); static bool isMySQLEvent(mxs_monitor_event_t event); +extern "C" +{ /** * The module entry point routine. It is this routine that * must populate the structure that is referred to as the @@ -100,6 +102,8 @@ MXS_MODULE* MXS_CREATE_MODULE() return &info; } + +} /*lint +e14 */ /** @@ -113,7 +117,7 @@ MXS_MODULE* MXS_CREATE_MODULE() static void * startMonitor(MXS_MONITOR *mon, const MXS_CONFIG_PARAMETER *params) { - MM_MONITOR *handle = mon->handle; + MM_MONITOR *handle = static_cast(mon->handle); if (handle) { @@ -653,7 +657,7 @@ detectStaleMaster(void *arg, int enable) static MXS_MONITORED_SERVER *get_current_master(MXS_MONITOR *mon) { - MM_MONITOR* handle = mon->handle; + MM_MONITOR* handle = static_cast(mon->handle); MXS_MONITORED_SERVER *ptr; ptr = mon->monitored_servers; diff --git a/server/modules/monitor/ndbclustermon/CMakeLists.txt b/server/modules/monitor/ndbclustermon/CMakeLists.txt index 69381583e..6b8428da7 100644 --- a/server/modules/monitor/ndbclustermon/CMakeLists.txt +++ b/server/modules/monitor/ndbclustermon/CMakeLists.txt @@ -1,4 +1,4 @@ -add_library(ndbclustermon SHARED ndbclustermon.c) +add_library(ndbclustermon SHARED ndbclustermon.cc) target_link_libraries(ndbclustermon maxscale-common) add_dependencies(ndbclustermon pcre2) set_target_properties(ndbclustermon PROPERTIES VERSION "2.1.0") diff --git a/server/modules/monitor/ndbclustermon/ndbclustermon.c b/server/modules/monitor/ndbclustermon/ndbclustermon.cc similarity index 99% rename from server/modules/monitor/ndbclustermon/ndbclustermon.c rename to server/modules/monitor/ndbclustermon/ndbclustermon.cc index 9cc119a66..9ea98774d 100644 --- a/server/modules/monitor/ndbclustermon/ndbclustermon.c +++ b/server/modules/monitor/ndbclustermon/ndbclustermon.cc @@ -38,6 +38,9 @@ bool isNdbEvent(mxs_monitor_event_t event); +extern "C" +{ + /** * The module entry point routine. It is this routine that * must populate the structure that is referred to as the @@ -91,6 +94,8 @@ MXS_MODULE* MXS_CREATE_MODULE() return &info; } + +} /*lint +e14 */ /** @@ -103,7 +108,7 @@ MXS_MODULE* MXS_CREATE_MODULE() static void * startMonitor(MXS_MONITOR *mon, const MXS_CONFIG_PARAMETER *params) { - NDBC_MONITOR *handle = mon->handle; + NDBC_MONITOR *handle = static_cast(mon->handle); bool have_events = false, script_error = false; if (handle != NULL)