From f7d97825fbffffd963273f806b724d49b951bd01 Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Mon, 14 Jan 2019 12:11:36 +0200 Subject: [PATCH] MXS-2219 Add monitor_stash_current_status The functions stores the current server status to the monitored server's mon_prev_status and pending_status fields. To be used at the start of the monitor loop, before the pending status fields are updated. --- include/maxscale/monitor.hh | 26 ++++++++++++++++++++++++-- server/core/monitor.cc | 18 ++++++------------ 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/include/maxscale/monitor.hh b/include/maxscale/monitor.hh index c3faacb10..3e1638324 100644 --- a/include/maxscale/monitor.hh +++ b/include/maxscale/monitor.hh @@ -297,8 +297,30 @@ extern const char CN_SCRIPT_TIMEOUT[]; bool check_monitor_permissions(MXS_MONITOR* monitor, const char* query); -void monitor_clear_pending_status(MXS_MONITORED_SERVER* ptr, uint64_t bit); -void monitor_set_pending_status(MXS_MONITORED_SERVER* ptr, uint64_t bit); +/** + * Store the current server status to the previous and pending status + * fields of the monitored server. + * + * @param mserver The monitored server to update + */ +void monitor_stash_current_status(MXS_MONITORED_SERVER* ptr); + +/** + * Clear pending status bits in the monitor server + * + * @param mserver The monitored server to update + * @param bit The bits to clear for the server + */ +void monitor_clear_pending_status(MXS_MONITORED_SERVER* mserver, uint64_t bit); + +/** + * Set pending status bits in the monitor server + * + * @param mserver The monitored server to update + * @param bit The bits to set for the server + */ +void monitor_set_pending_status(MXS_MONITORED_SERVER* mserver, uint64_t bit); + void monitor_check_maintenance_requests(MXS_MONITOR* monitor); bool mon_status_changed(MXS_MONITORED_SERVER* mon_srv); diff --git a/server/core/monitor.cc b/server/core/monitor.cc index 1cc91e147..59013b3e4 100644 --- a/server/core/monitor.cc +++ b/server/core/monitor.cc @@ -931,23 +931,17 @@ void mon_alter_parameter(MXS_MONITOR* monitor, const char* key, const char* valu pthread_mutex_unlock(&monitor->lock); } -/** - * Set pending status bits in the monitor server - * - * @param server The server to update - * @param bit The bits to set for the server - */ +void monitor_stash_current_status(MXS_MONITORED_SERVER* ptr) +{ + ptr->mon_prev_status = ptr->server->status; + ptr->pending_status = ptr->server->status; +} + void monitor_set_pending_status(MXS_MONITORED_SERVER* ptr, uint64_t bit) { ptr->pending_status |= bit; } -/** - * Clear pending status bits in the monitor server - * - * @param server The server to update - * @param bit The bits to clear for the server - */ void monitor_clear_pending_status(MXS_MONITORED_SERVER* ptr, uint64_t bit) { ptr->pending_status &= ~bit;