mysql_client_server_protocol.h :

changed gw_receive_backend_auth declaration to return int instead of boolean.
mysql_backend.c:
	gw_read_backend_event calls gw_receive_backend_auth which either fails (== -1), succeeds with nothing to read (== 0) or succeeds (== 1). For each case there is handling. If dcb_read succeeds without read bytes, return asap.
mysql_client.c:
	gw_error_client_event, gw_client_close, gw_client_hangup_event : all close client dcb but now they also close backend dcb.
mysql_common.c:
	gw_receive_backend_auth, return -1, 0, or 1 if read from backend failed, was empty, or succeed, respectively.:
This commit is contained in:
vraatikka
2013-10-07 14:00:44 +03:00
parent 80b67d1083
commit 655a6537b2
6 changed files with 138 additions and 34 deletions

View File

@ -203,6 +203,7 @@ static int gw_read_backend_event(DCB *dcb) {
ROUTER *router_instance = NULL;
void *rsession = NULL;
SESSION *session = dcb->session;
int receive_rc = 0;
CHK_SESSION(session);
@ -213,21 +214,46 @@ static int gw_read_backend_event(DCB *dcb) {
/**
* Read backed auth reply
*/
if (gw_receive_backend_auth(backend_protocol)) {
backend_protocol->state = MYSQL_IDLE;
} else {
backend_protocol->state = MYSQL_AUTH_FAILED;
receive_rc = gw_receive_backend_auth(backend_protocol);
switch (receive_rc) {
case -1:
backend_protocol->state = MYSQL_AUTH_FAILED;
skygw_log_write_flush(
LOGFILE_ERROR,
"Error : backend server didn't accept "
"authentication for user %s.",
current_session->user);
break;
case 1:
backend_protocol->state = MYSQL_IDLE;
skygw_log_write_flush(
LOGFILE_TRACE,
"%lu [gw_read_backend_event] "
"gw_receive_backend_auth failed. dcb "
"gw_receive_backend_auth succeed. dcb "
"%p fd %d, user %s.",
pthread_self(),
dcb,
dcb->fd,
current_session->user);
}
break;
default:
ss_dassert(receive_rc == 0);
skygw_log_write_flush(
LOGFILE_TRACE,
"%lu [gw_read_backend_event] "
"gw_receive_backend_auth read "
"successfully "
"nothing. dcb %p fd %d, user %s.",
pthread_self(),
dcb,
dcb->fd,
current_session->user);
rc = 0;
goto return_rc;
break;
} /* switch */
}
if (backend_protocol->state == MYSQL_AUTH_FAILED) {
@ -294,7 +320,7 @@ static int gw_read_backend_event(DCB *dcb) {
/* reading MySQL command output from backend and writing to the client */
{
GWBUF *head = NULL;
GWBUF *writebuf = NULL;
ROUTER_OBJECT *router = NULL;
ROUTER *router_instance = NULL;
void *rsession = NULL;
@ -302,7 +328,7 @@ static int gw_read_backend_event(DCB *dcb) {
CHK_SESSION(session);
/* read available backend data */
rc = dcb_read(dcb, &head);
rc = dcb_read(dcb, &writebuf);
if (rc < 0) {
/**
@ -314,6 +340,11 @@ static int gw_read_backend_event(DCB *dcb) {
rc = 0;
goto return_rc;
}
if (writebuf == NULL) {
rc = 0;
goto return_rc;
}
router = session->service->router;
router_instance = session->service->router_instance;
rsession = session->router_session;
@ -341,7 +372,7 @@ static int gw_read_backend_event(DCB *dcb) {
{
router->clientReply(router_instance,
rsession,
head,
writebuf,
dcb);
rc = 1;
}