diff --git a/include/maxscale/monitor.hh b/include/maxscale/monitor.hh index 2456ec85b..31f076f9e 100644 --- a/include/maxscale/monitor.hh +++ b/include/maxscale/monitor.hh @@ -134,9 +134,9 @@ public: /** * Maintenance mode request constants. */ - static const int MAINTENANCE_OFF = -100; - static const int MAINTENANCE_NO_CHANGE = 0; - static const int MAINTENANCE_ON = 100; + static const int SERVER_NO_CHANGE = 0; + static const int SERVER_MAINT_OFF = 1; + static const int SERVER_MAINT_ON = 2; SERVER* server = nullptr; /**< The server being monitored */ MYSQL* con = nullptr; /**< The MySQL connection */ @@ -145,8 +145,8 @@ public: uint64_t mon_prev_status = -1; /**< Status before starting the current monitor loop */ uint64_t pending_status = 0; /**< Status during current monitor loop */ int64_t disk_space_checked = 0; /**< When was the disk space checked the last time */ - int maint_request = MAINTENANCE_NO_CHANGE; /**< Is admin requesting Maintenance=ON/OFF on the - * server? */ + int status_request = SERVER_NO_CHANGE; /**< Is admin requesting Maintenance=ON/OFF on the + * server? */ }; #define MAX_MONITOR_USER_LEN 512 @@ -162,8 +162,8 @@ public: virtual ~Monitor(); virtual bool configure(const MXS_CONFIG_PARAMETER* params) = 0; - static const int MAINTENANCE_FLAG_NOCHECK = 0; - static const int MAINTENANCE_FLAG_CHECK = -1; + static const int STATUS_FLAG_NOCHECK = 0; + static const int STATUS_FLAG_CHECK = -1; /** * Starts the monitor. If the monitor requires polling of the servers, it should create @@ -240,7 +240,7 @@ public: /** The state of the monitor. This should ONLY be written to by the admin thread. */ monitor_state_t m_state {MONITOR_STATE_STOPPED}; /** Set when admin requests a maintenance status change. */ - int check_maintenance_flag = MAINTENANCE_FLAG_NOCHECK; + int check_status_flag = STATUS_FLAG_NOCHECK; uint64_t m_ticks {0}; /**< Number of performed monitoring intervals */ uint8_t m_journal_hash[SHA_DIGEST_LENGTH]; /**< SHA1 hash of the latest written journal */ diff --git a/server/core/monitor.cc b/server/core/monitor.cc index c83ffd1f7..60e5fac2c 100644 --- a/server/core/monitor.cc +++ b/server/core/monitor.cc @@ -1588,21 +1588,21 @@ void monitor_check_maintenance_requests(Monitor* monitor) { /* In theory, the admin may be modifying the server maintenance status during this function. The overall * maintenance flag should be read-written atomically to prevent missing a value. */ - int flags_changed = atomic_exchange_int(&monitor->check_maintenance_flag, - Monitor::MAINTENANCE_FLAG_NOCHECK); - if (flags_changed != Monitor::MAINTENANCE_FLAG_NOCHECK) + int flags_changed = atomic_exchange_int(&monitor->check_status_flag, + Monitor::STATUS_FLAG_NOCHECK); + if (flags_changed != Monitor::STATUS_FLAG_NOCHECK) { for (auto ptr : monitor->m_servers) { // The only server status bit the admin may change is the [Maintenance] bit. - int admin_msg = atomic_exchange_int(&ptr->maint_request, - MXS_MONITORED_SERVER::MAINTENANCE_NO_CHANGE); - if (admin_msg == MXS_MONITORED_SERVER::MAINTENANCE_ON) + int admin_msg = atomic_exchange_int(&ptr->status_request, + MXS_MONITORED_SERVER::SERVER_NO_CHANGE); + if (admin_msg == MXS_MONITORED_SERVER::SERVER_MAINT_ON) { // TODO: Change to writing MONITORED_SERVER->pending status instead once cleanup done. ptr->server->set_status(SERVER_MAINT); } - else if (admin_msg == MXS_MONITORED_SERVER::MAINTENANCE_OFF) + else if (admin_msg == MXS_MONITORED_SERVER::SERVER_MAINT_OFF) { ptr->server->clear_status(SERVER_MAINT); } @@ -2387,16 +2387,16 @@ bool Monitor::set_server_status(SERVER* srv, int bit, string* errmsg_out) { /* Maintenance is set/cleared using a special variable which the monitor reads when * starting the next update cycle. */ - int previous_request = atomic_exchange_int(&msrv->maint_request, - MXS_MONITORED_SERVER::MAINTENANCE_ON); + int previous_request = atomic_exchange_int(&msrv->status_request, + MXS_MONITORED_SERVER::SERVER_MAINT_ON); written = true; // Warn if the previous request hasn't been read. - if (previous_request != MXS_MONITORED_SERVER::MAINTENANCE_NO_CHANGE) + if (previous_request != MXS_MONITORED_SERVER::SERVER_NO_CHANGE) { MXS_WARNING(WRN_REQUEST_OVERWRITTEN); } // Also set a flag so the next loop happens sooner. - atomic_store_int(&this->check_maintenance_flag, Monitor::MAINTENANCE_FLAG_CHECK); + atomic_store_int(&this->check_status_flag, Monitor::STATUS_FLAG_CHECK); } else { @@ -2442,14 +2442,14 @@ bool Monitor::clear_server_status(SERVER* srv, int bit, string* errmsg_out) else if (bit & SERVER_MAINT) { // Warn if the previous request hasn't been read. - int previous_request = atomic_exchange_int(&msrv->maint_request, - MXS_MONITORED_SERVER::MAINTENANCE_OFF); + int previous_request = atomic_exchange_int(&msrv->status_request, + MXS_MONITORED_SERVER::SERVER_MAINT_OFF); written = true; - if (previous_request != MXS_MONITORED_SERVER::MAINTENANCE_NO_CHANGE) + if (previous_request != MXS_MONITORED_SERVER::SERVER_NO_CHANGE) { MXS_WARNING(WRN_REQUEST_OVERWRITTEN); } - atomic_store_int(&this->check_maintenance_flag, Monitor::MAINTENANCE_FLAG_CHECK); + atomic_store_int(&this->check_status_flag, Monitor::STATUS_FLAG_CHECK); } else { @@ -2920,7 +2920,7 @@ bool MonitorWorker::call_run_one_tick(Worker::Call::action_t action) // Enough time has passed, if ((now - m_loop_called > m_settings.interval) // or maintenance flag is set, - || atomic_load_int(&this->check_maintenance_flag) == Monitor::MAINTENANCE_FLAG_CHECK + || atomic_load_int(&this->check_status_flag) == Monitor::STATUS_FLAG_CHECK // or a monitor-specific condition is met. || immediate_tick_required()) {