Change session id to 64bit
The server internal session id may be larger than 4 bytes (MariaDB uses 8) but only 4 are sent in the handshake. The full value can be queried from the server, but this query is not supported by MaxScale yet. In any case, both the protocol and MXS_SESSION now have 64 bit counters. Only the low 32 bits are sent in the handshake, similar to server.
This commit is contained in:
@ -241,9 +241,10 @@ int MySQLSendHandshake(DCB* dcb)
|
||||
memcpy(mysql_filler_ten + 6, &new_flags, sizeof(new_flags));
|
||||
}
|
||||
|
||||
// Get the equivalent of the server process id.
|
||||
protocol->tid = session_get_next_id();
|
||||
gw_mysql_set_byte4(mysql_thread_id_num, protocol->tid);
|
||||
// Get the equivalent of the server thread id.
|
||||
protocol->thread_id = session_get_next_id();
|
||||
// Send only the low 32bits in the handshake.
|
||||
gw_mysql_set_byte4(mysql_thread_id_num, (uint32_t)(protocol->thread_id));
|
||||
memcpy(mysql_scramble_buf, server_scramble, 8);
|
||||
|
||||
memcpy(mysql_plugin_data, server_scramble + 8, 12);
|
||||
@ -668,7 +669,7 @@ gw_read_do_authentication(DCB *dcb, GWBUF *read_buffer, int nbytes_read)
|
||||
* normal data handling function instead of this one.
|
||||
*/
|
||||
MXS_SESSION *session =
|
||||
session_alloc_with_id(dcb->service, dcb, protocol->tid);
|
||||
session_alloc_with_id(dcb->service, dcb, protocol->thread_id);
|
||||
|
||||
if (session != NULL)
|
||||
{
|
||||
|
@ -1410,7 +1410,6 @@ gw_decode_mysql_server_handshake(MySQLProtocol *conn, uint8_t *payload)
|
||||
uint8_t *server_version_end = NULL;
|
||||
uint16_t mysql_server_capabilities_one = 0;
|
||||
uint16_t mysql_server_capabilities_two = 0;
|
||||
unsigned long tid = 0;
|
||||
uint8_t scramble_data_1[GW_SCRAMBLE_LENGTH_323] = "";
|
||||
uint8_t scramble_data_2[GW_MYSQL_SCRAMBLE_SIZE - GW_SCRAMBLE_LENGTH_323] = "";
|
||||
uint8_t capab_ptr[4] = "";
|
||||
@ -1433,8 +1432,10 @@ gw_decode_mysql_server_handshake(MySQLProtocol *conn, uint8_t *payload)
|
||||
payload = server_version_end + 1;
|
||||
|
||||
// get ThreadID: 4 bytes
|
||||
tid = gw_mysql_get_byte4(payload);
|
||||
memcpy(&conn->tid, &tid, 4);
|
||||
uint32_t tid = gw_mysql_get_byte4(payload);
|
||||
/* TODO: Correct value of thread id could be queried later from backend if
|
||||
* there is any worry it might be larger than 32bit allows. */
|
||||
conn->thread_id = tid;
|
||||
|
||||
payload += 4;
|
||||
|
||||
|
Reference in New Issue
Block a user