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.
This commit is contained in:
Johan Wikman 2019-01-14 12:11:36 +02:00
parent 7f6f5191cc
commit f7d97825fb
2 changed files with 30 additions and 14 deletions

View File

@ -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);

View File

@ -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;