Merge branch 'SESvars' of https://github.com/skysql/MaxScale into SESvars
Conflicts: server/core/dcb.c server/core/poll.c server/modules/include/mysql_client_server_protocol.h server/modules/routing/readwritesplit/readwritesplit.c
This commit is contained in:
@ -283,6 +283,8 @@ static int gw_read_backend_event(DCB *dcb) {
|
||||
}
|
||||
|
||||
if (backend_protocol->state == MYSQL_AUTH_FAILED) {
|
||||
|
||||
spinlock_acquire(&dcb->delayqlock);
|
||||
/*<
|
||||
* vraa : errorHandle
|
||||
* check the delayq before the reply
|
||||
@ -295,10 +297,12 @@ static int gw_read_backend_event(DCB *dcb) {
|
||||
0,
|
||||
"Connection to backend lost.");
|
||||
// consume all the delay queue
|
||||
dcb->delayq = gwbuf_consume(
|
||||
while ((dcb->delayq = gwbuf_consume(
|
||||
dcb->delayq,
|
||||
gwbuf_length(dcb->delayq));
|
||||
GWBUF_LENGTH(dcb->delayq))) != NULL);
|
||||
}
|
||||
spinlock_release(&dcb->delayqlock);
|
||||
|
||||
|
||||
/* try reload users' table for next connection */
|
||||
service_refresh_users(dcb->session->client->service);
|
||||
@ -350,7 +354,7 @@ static int gw_read_backend_event(DCB *dcb) {
|
||||
pthread_self(),
|
||||
dcb->fd,
|
||||
current_session->user)));
|
||||
|
||||
|
||||
/* check the delay queue and flush the data */
|
||||
if (dcb->delayq)
|
||||
{
|
||||
@ -524,7 +528,7 @@ gw_MySQLWrite_backend(DCB *dcb, GWBUF *queue)
|
||||
/*<
|
||||
* Don't write to backend if backend_dcb is not in poll set anymore.
|
||||
*/
|
||||
spinlock_acquire(&dcb->authlock);
|
||||
spinlock_acquire(&dcb->dcb_initlock);
|
||||
if (dcb->state != DCB_STATE_POLLING) {
|
||||
/*< vraa : errorHandle */
|
||||
/*< Free buffer memory */
|
||||
@ -539,10 +543,12 @@ gw_MySQLWrite_backend(DCB *dcb, GWBUF *queue)
|
||||
dcb->fd,
|
||||
STRDCBSTATE(dcb->state))));
|
||||
|
||||
spinlock_release(&dcb->authlock);
|
||||
spinlock_release(&dcb->dcb_initlock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
spinlock_release(&dcb->dcb_initlock);
|
||||
|
||||
spinlock_acquire(&dcb->authlock);
|
||||
/*<
|
||||
* Now put the incoming data to the delay queue unless backend is
|
||||
* connected with auth ok
|
||||
@ -556,7 +562,6 @@ gw_MySQLWrite_backend(DCB *dcb, GWBUF *queue)
|
||||
dcb,
|
||||
dcb->fd,
|
||||
STRPROTOCOLSTATE(backend_protocol->state))));
|
||||
|
||||
backend_set_delayqueue(dcb, queue);
|
||||
spinlock_release(&dcb->authlock);
|
||||
return 1;
|
||||
@ -565,8 +570,6 @@ gw_MySQLWrite_backend(DCB *dcb, GWBUF *queue)
|
||||
/*<
|
||||
* Now we set the last command received, from the current queue
|
||||
*/
|
||||
memcpy(&dcb->command, &queue->command, sizeof(dcb->command));
|
||||
|
||||
spinlock_release(&dcb->authlock);
|
||||
rc = dcb_write(dcb, queue);
|
||||
return rc;
|
||||
@ -804,12 +807,6 @@ static int backend_write_delayqueue(DCB *dcb)
|
||||
localq = dcb->delayq;
|
||||
dcb->delayq = NULL;
|
||||
|
||||
/*<
|
||||
* Now we set the last command received, from the delayed queue
|
||||
*/
|
||||
|
||||
memcpy(&dcb->command, &localq->command, sizeof(dcb->command));
|
||||
|
||||
spinlock_release(&dcb->delayqlock);
|
||||
rc = dcb_write(dcb, localq);
|
||||
|
||||
@ -851,15 +848,12 @@ static int gw_change_user(DCB *backend, SERVER *server, SESSION *in_session, GWB
|
||||
unsigned int auth_token_len = 0;
|
||||
uint8_t *auth_token = NULL;
|
||||
int rv = -1;
|
||||
int len = 0;
|
||||
int auth_ret = 1;
|
||||
|
||||
current_session = (MYSQL_session *)in_session->client->data;
|
||||
backend_protocol = backend->protocol;
|
||||
client_protocol = in_session->client->protocol;
|
||||
|
||||
queue->command = ROUTER_CHANGE_SESSION;
|
||||
|
||||
// now get the user, after 4 bytes header and 1 byte command
|
||||
client_auth_packet += 5;
|
||||
strcpy(username, (char *)client_auth_packet);
|
||||
@ -910,31 +904,14 @@ static int gw_change_user(DCB *backend, SERVER *server, SESSION *in_session, GWB
|
||||
|
||||
rv = gw_send_change_user_to_backend(database, username, client_sha1, backend_protocol);
|
||||
|
||||
/*<
|
||||
* The current queue was not handled by func.write() in gw_send_change_user_to_backend()
|
||||
* We wrote a new gwbuf
|
||||
* Set backend command here!
|
||||
*/
|
||||
memcpy(&backend->command, &queue->command, sizeof(backend->command));
|
||||
|
||||
/*<
|
||||
* Now copy new data into user session
|
||||
*/
|
||||
strcpy(current_session->user, username);
|
||||
strcpy(current_session->db, database);
|
||||
memcpy(current_session->client_sha1, client_sha1, sizeof(current_session->client_sha1));
|
||||
|
||||
}
|
||||
|
||||
// consume all the data received from client
|
||||
|
||||
spinlock_acquire(&backend->writeqlock);
|
||||
|
||||
len = gwbuf_length(queue);
|
||||
queue = gwbuf_consume(queue, len);
|
||||
|
||||
spinlock_release(&backend->writeqlock);
|
||||
|
||||
}
|
||||
gwbuf_free(queue);
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -951,7 +928,6 @@ static int gw_session(DCB *backend_dcb, void *data) {
|
||||
GWBUF *queue = NULL;
|
||||
|
||||
queue = (GWBUF *) data;
|
||||
queue->command = ROUTER_CHANGE_SESSION;
|
||||
backend_dcb->func.write(backend_dcb, queue);
|
||||
|
||||
return 1;
|
||||
|
Reference in New Issue
Block a user