MXS-2196: Allocate a session before allocating DCBs

Allocating the session before a DCB guarantees that at no point will a DCB
have a null session. This further clarifies the concept of the session and
also allows the listener reference to be moved there.

Ideally, the session itself would allocate and assign the client DCB but
since the Listener is the only one who does it, it's acceptable for now.
This commit is contained in:
Markus Mäkelä
2018-12-03 19:25:26 +02:00
parent 692127a2cb
commit 43c33e9f4a
20 changed files with 106 additions and 115 deletions

View File

@ -293,7 +293,7 @@ static int mysql_auth_authenticate(DCB* dcb)
client_data->user,
client_data->db);
MYSQL_AUTH* instance = (MYSQL_AUTH*)dcb->listener->auth_instance();
MYSQL_AUTH* instance = (MYSQL_AUTH*)dcb->session->listener->auth_instance();
MySQLProtocol* protocol = DCB_PROTOCOL(dcb, MySQLProtocol);
auth_ret = validate_mysql_user(instance,
dcb,
@ -684,7 +684,7 @@ int mysql_auth_reauthenticate(DCB* dcb,
temp.auth_token = token;
temp.auth_token_len = token_len;
MYSQL_AUTH* instance = (MYSQL_AUTH*)dcb->listener->auth_instance();
MYSQL_AUTH* instance = (MYSQL_AUTH*)dcb->session->listener->auth_instance();
int rc = validate_mysql_user(instance, dcb, &temp, scramble, scramble_len);
if (rc != MXS_AUTH_SUCCEEDED && service_refresh_users(dcb->service) == 0)