dcb->state set wheere missing or changed

This commit is contained in:
Massimiliano Pinto
2013-08-27 10:52:43 +02:00
parent d0d68a69ca
commit ff109c6319
2 changed files with 16 additions and 9 deletions

View File

@ -120,6 +120,8 @@ static int gw_read_backend_event(DCB *dcb) {
MySQLProtocol *backend_protocol = NULL;
MYSQL_session *current_session = NULL;
dcb->state = DCB_STATE_PROCESSING;
if(dcb->session) {
client_protocol = SESSION_PROTOCOL(dcb->session, MySQLProtocol);
}
@ -143,6 +145,7 @@ static int gw_read_backend_event(DCB *dcb) {
current_session->client_sha1,
backend_protocol);
dcb->state = DCB_STATE_POLLING;
return 1;
}
@ -206,6 +209,7 @@ static int gw_read_backend_event(DCB *dcb) {
"backend session.",
pthread_self());
}
dcb->state = DCB_STATE_POLLING;
return 1;
case MYSQL_SUCCESFUL_AUTHENTICATION:
@ -225,15 +229,18 @@ static int gw_read_backend_event(DCB *dcb) {
/* check the delay queue and flush the data */
if(dcb->delayq) {
backend_write_delayqueue(dcb);
dcb->state = DCB_STATE_POLLING;
spinlock_release(&dcb->authlock);
return 1;
}
dcb->state = DCB_STATE_POLLING;
spinlock_release(&dcb->authlock);
return 1;
default:
/* no other authentication state here right now, so just return */
dcb->state = DCB_STATE_POLLING;
return 0;
}
}
@ -271,10 +278,12 @@ static int gw_read_backend_event(DCB *dcb) {
/* and pass now the gwbuf to the router */
router->clientReply(router_instance, rsession, head, dcb);
dcb->state = DCB_STATE_POLLING;
return 1;
}
dcb->state = DCB_STATE_POLLING;
return 0;
}
@ -286,22 +295,27 @@ static int gw_read_backend_event(DCB *dcb) {
*/
static int gw_write_backend_event(DCB *dcb) {
MySQLProtocol *backend_protocol = dcb->protocol;
int w = 0;
//fprintf(stderr, ">>> backend EPOLLOUT %i, protocol state [%s]\n", backend_protocol->fd, gw_mysql_protocol_state2string(backend_protocol->state));
// spinlock_acquire(&dcb->connectlock);
dcb->state = DCB_STATE_PROCESSING;
if (backend_protocol->state == MYSQL_PENDING_CONNECT) {
backend_protocol->state = MYSQL_CONNECTED;
// spinlock_release(&dcb->connectlock);
dcb->state = DCB_STATE_POLLING;
return 1;
}
// spinlock_release(&dcb->connectlock);
return dcb_drain_writeq(dcb);
w = dcb_drain_writeq(dcb);
dcb->state = DCB_STATE_POLLING;
return 1;
}
/*

View File

@ -118,8 +118,6 @@ int gw_read_backend_handshake(MySQLProtocol *conn) {
uint8_t *payload = NULL;
if ((n = dcb_read(dcb, &head)) != -1) {
dcb->state = DCB_STATE_PROCESSING;
if (head) {
payload = GWBUF_DATA(head);
@ -134,8 +132,6 @@ int gw_read_backend_handshake(MySQLProtocol *conn) {
// consume all the data here
head = gwbuf_consume(head, gwbuf_length(head));
dcb->state = DCB_STATE_POLLING;
return 0;
}
}
@ -230,7 +226,6 @@ int gw_receive_backend_auth(MySQLProtocol *conn) {
uint8_t *ptr = NULL;
if ((n = dcb_read(dcb, &head)) != -1) {
dcb->state = DCB_STATE_PROCESSING;
if (head) {
ptr = GWBUF_DATA(head);
// check if the auth is SUCCESFUL
@ -246,8 +241,6 @@ int gw_receive_backend_auth(MySQLProtocol *conn) {
}
}
dcb->state = DCB_STATE_POLLING;
return rv;
}