Simplify handling of "client data" by having a pointer to it only in DCB and not in session structure. Change name of session->client to session->client_dcb for greater clarity. Temporary free of client data in DCB, to be moved to authenticator when it becomes a module. Fix incorrect name of listener_alloc.
This commit is contained in:
@ -139,7 +139,7 @@ static MYSQL_session* gw_get_shared_session_auth_info(DCB* dcb)
|
||||
|
||||
if (dcb->session->state != SESSION_STATE_ALLOC && dcb->session->state != SESSION_STATE_DUMMY)
|
||||
{
|
||||
auth_info = dcb->session->data;
|
||||
auth_info = dcb->session->client_dcb->data;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -549,8 +549,8 @@ static int gw_read_backend_event(DCB *dcb)
|
||||
* still listening the socket for replies.
|
||||
*/
|
||||
if (dcb->session->state == SESSION_STATE_ROUTER_READY &&
|
||||
dcb->session->client != NULL &&
|
||||
dcb->session->client->state == DCB_STATE_POLLING &&
|
||||
dcb->session->client_dcb != NULL &&
|
||||
dcb->session->client_dcb->state == DCB_STATE_POLLING &&
|
||||
(session->router_session || router->getCapabilities() & RCAP_TYPE_NO_RSESSION))
|
||||
{
|
||||
client_protocol = SESSION_PROTOCOL(dcb->session,
|
||||
@ -571,7 +571,7 @@ static int gw_read_backend_event(DCB *dcb)
|
||||
}
|
||||
goto return_rc;
|
||||
}
|
||||
else if (dcb->session->client->dcb_role == DCB_ROLE_INTERNAL)
|
||||
else if (dcb->session->client_dcb->dcb_role == DCB_ROLE_INTERNAL)
|
||||
{
|
||||
gwbuf_set_type(read_buffer, GWBUF_TYPE_MYSQL);
|
||||
router->clientReply(router_instance, session->router_session, read_buffer, dcb);
|
||||
@ -614,14 +614,14 @@ static int gw_write_backend_event(DCB *dcb)
|
||||
{
|
||||
data = (uint8_t *)GWBUF_DATA(dcb->writeq);
|
||||
|
||||
if (dcb->session->client == NULL)
|
||||
if (dcb->session->client_dcb == NULL)
|
||||
{
|
||||
rc = 0;
|
||||
}
|
||||
else if (!(MYSQL_IS_COM_QUIT(data)))
|
||||
{
|
||||
/*< vraa : errorHandle */
|
||||
mysql_send_custom_error(dcb->session->client,
|
||||
mysql_send_custom_error(dcb->session->client_dcb,
|
||||
1,
|
||||
0,
|
||||
"Writing to backend failed due invalid Maxscale "
|
||||
@ -937,14 +937,14 @@ static int gw_create_backend_connection(DCB *backend_dcb,
|
||||
}
|
||||
|
||||
/** Copy client flags to backend protocol */
|
||||
if (backend_dcb->session->client->protocol)
|
||||
if (backend_dcb->session->client_dcb->protocol)
|
||||
{
|
||||
/** Copy client flags to backend protocol */
|
||||
protocol->client_capabilities =
|
||||
((MySQLProtocol *)(backend_dcb->session->client->protocol))->client_capabilities;
|
||||
((MySQLProtocol *)(backend_dcb->session->client_dcb->protocol))->client_capabilities;
|
||||
/** Copy client charset to backend protocol */
|
||||
protocol->charset =
|
||||
((MySQLProtocol *)(backend_dcb->session->client->protocol))->charset;
|
||||
((MySQLProtocol *)(backend_dcb->session->client_dcb->protocol))->charset;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -971,7 +971,7 @@ static int gw_create_backend_connection(DCB *backend_dcb,
|
||||
server->name,
|
||||
server->port,
|
||||
protocol->fd,
|
||||
session->client->fd);
|
||||
session->client_dcb->fd);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
@ -984,7 +984,7 @@ static int gw_create_backend_connection(DCB *backend_dcb,
|
||||
server->name,
|
||||
server->port,
|
||||
protocol->fd,
|
||||
session->client->fd);
|
||||
session->client_dcb->fd);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -996,7 +996,7 @@ static int gw_create_backend_connection(DCB *backend_dcb,
|
||||
server->name,
|
||||
server->port,
|
||||
protocol->fd,
|
||||
session->client->fd);
|
||||
session->client_dcb->fd);
|
||||
break;
|
||||
} /*< switch */
|
||||
|
||||
@ -1148,7 +1148,7 @@ static int gw_backend_close(DCB *dcb)
|
||||
CHK_SESSION(session);
|
||||
/**
|
||||
* The lock is needed only to protect the read of session->state and
|
||||
* session->client values. Client's state may change by other thread
|
||||
* session->client_dcb values. Client's state may change by other thread
|
||||
* but client's close and adding client's DCB to zombies list is executed
|
||||
* only if client's DCB's state does _not_ change in parallel.
|
||||
*/
|
||||
@ -1158,16 +1158,16 @@ static int gw_backend_close(DCB *dcb)
|
||||
* Otherwise only this backend connection is closed.
|
||||
*/
|
||||
if (session->state == SESSION_STATE_STOPPING &&
|
||||
session->client != NULL)
|
||||
session->client_dcb != NULL)
|
||||
{
|
||||
if (session->client->state == DCB_STATE_POLLING)
|
||||
if (session->client_dcb->state == DCB_STATE_POLLING)
|
||||
{
|
||||
DCB *temp;
|
||||
spinlock_release(&session->ses_lock);
|
||||
|
||||
/** Close client DCB */
|
||||
temp = session->client;
|
||||
session->client = NULL;
|
||||
temp = session->client_dcb;
|
||||
session->client_dcb = NULL;
|
||||
dcb_close(temp);
|
||||
}
|
||||
else
|
||||
@ -1243,7 +1243,7 @@ static int backend_write_delayqueue(DCB *dcb)
|
||||
MYSQL_session* mses;
|
||||
GWBUF* new_packet;
|
||||
|
||||
mses = (MYSQL_session *)dcb->session->client->data;
|
||||
mses = (MYSQL_session *)dcb->session->client_dcb->data;
|
||||
new_packet = gw_create_change_user_packet(mses,
|
||||
(MySQLProtocol *)dcb->protocol);
|
||||
/**
|
||||
@ -1327,9 +1327,9 @@ static int gw_change_user(DCB *backend,
|
||||
int rv = -1;
|
||||
int auth_ret = 1;
|
||||
|
||||
current_session = (MYSQL_session *)in_session->client->data;
|
||||
current_session = (MYSQL_session *)in_session->client_dcb->data;
|
||||
backend_protocol = backend->protocol;
|
||||
client_protocol = in_session->client->protocol;
|
||||
client_protocol = in_session->client_dcb->protocol;
|
||||
|
||||
/* now get the user, after 4 bytes header and 1 byte command */
|
||||
client_auth_packet += 5;
|
||||
@ -1386,7 +1386,7 @@ static int gw_change_user(DCB *backend,
|
||||
* decode the token and check the password.
|
||||
* Note: if auth_token_len == 0 && auth_token == NULL, user is without password
|
||||
*/
|
||||
auth_ret = gw_check_mysql_scramble_data(backend->session->client,
|
||||
auth_ret = gw_check_mysql_scramble_data(backend->session->client_dcb,
|
||||
auth_token,
|
||||
auth_token_len,
|
||||
client_protocol->scramble,
|
||||
@ -1396,11 +1396,11 @@ static int gw_change_user(DCB *backend,
|
||||
|
||||
if (auth_ret != 0)
|
||||
{
|
||||
if (!service_refresh_users(backend->session->client->service))
|
||||
if (!service_refresh_users(backend->session->client_dcb->service))
|
||||
{
|
||||
/* Try authentication again with new repository data */
|
||||
/* Note: if no auth client authentication will fail */
|
||||
auth_ret = gw_check_mysql_scramble_data(backend->session->client,
|
||||
auth_ret = gw_check_mysql_scramble_data(backend->session->client_dcb,
|
||||
auth_token, auth_token_len,
|
||||
client_protocol->scramble,
|
||||
sizeof(client_protocol->scramble),
|
||||
@ -1441,7 +1441,7 @@ static int gw_change_user(DCB *backend,
|
||||
* reply to the client.
|
||||
*/
|
||||
message = create_auth_fail_str(username,
|
||||
backend->session->client->remote,
|
||||
backend->session->client_dcb->remote,
|
||||
password_set,
|
||||
"",
|
||||
auth_ret);
|
||||
|
Reference in New Issue
Block a user