Only write to SERVER->status at the end of a monitoring loop

This makes the code clearer and reduces race conditions, as the monitor
could be writing SERVER->status while a router is reading it. Also,
the time during which the SERVER struct is locked drops to a fraction.
This commit is contained in:
Esa Korhonen
2018-05-17 14:27:16 +03:00
parent 715b8a6f1d
commit 3ec449339f
6 changed files with 183 additions and 118 deletions

View File

@ -205,6 +205,16 @@ public:
*/
bool is_down() const;
/**
* Convenience method for SERVER_IN_MAINT
*/
bool is_in_maintenance() const;
/**
* Convenience method for SERVER_IS_RELAY_SERVER
*/
bool is_relay_server() const;
/**
* Returns the server name.
*
@ -299,6 +309,20 @@ public:
*/
void update_server(MXS_MONITOR* base_monitor);
/**
* Clear server pending status flags.
*
* @param bits Which flags to clear
*/
void clear_status(uint64_t bits);
/**
* Set server pending status flags.
*
* @param bits Which flags to set
*/
void set_status(uint64_t bits);
private:
void monitor_server(MXS_MONITOR* base_monitor);
bool update_slave_status(std::string* errmsg_out = NULL);