Improve charset selection

The charset sent in the handshake is now done with the following
priorities:

* First Master server
* Last Slave server
* First Running server or Down server whose charset is known

The change is that server in the Down state to which we've successfully
connected to can also be used as the charset source. This, in addition
with an "empty" default charset, helps avoid the use of the default latin1
charset unless absolutely necessary.
This commit is contained in:
Markus Mäkelä
2020-03-11 23:46:35 +02:00
parent caf3b4cf75
commit 291d2e987f
3 changed files with 17 additions and 8 deletions

View File

@ -181,8 +181,10 @@ public:
* routing sessions. */
// Base variables
bool is_active = false; /**< Server is active and has not been "destroyed" */
uint8_t charset = DEFAULT_CHARSET; /**< Character set. Read from backend and sent to client. */
bool is_active = false; /**< Server is active and has not been "destroyed" */
uint8_t charset = 0; /**< Character set. Read from backend and sent to client. As no character set
* has the numeric value of 0, it can be used to detect servers we haven't
* connected to. */
// Statistics and events
ConnStats stats; /**< The server statistics, e.g. number of connections */
@ -535,7 +537,6 @@ protected:
}
private:
static const int DEFAULT_CHARSET = 0x08; /**< The latin1 charset */
maxbase::EMAverage m_response_time; /**< Response time calculations for this server */
std::mutex m_average_write_mutex; /**< Protects response time from concurrent writing */
mxs::SSLProvider m_ssl_provider;