mysql_backend.c:gw_read_backend event

If backend authentication fails, wait until session has created router_client_session before reading the session->router_session pointer value. There should only be one case where this situation occurs : when session is being initialized concurrently with authentication. Only consequence is to close router_client_session immediately after session initialization is completed.
This commit is contained in:
VilhoRaatikka
2014-01-27 16:54:48 +02:00
parent aab09ddd16
commit ef90f648a2
2 changed files with 18 additions and 8 deletions

View File

@ -299,13 +299,17 @@ static int gw_read_backend_event(DCB *dcb) {
dcb->delayq, dcb->delayq,
gwbuf_length(dcb->delayq)); gwbuf_length(dcb->delayq));
} }
rsession = session->router_session; ss_dassert(session->state == SESSION_READY);
ss_dassert(rsession != NULL); /**
/*<
* vraa : errorHandle * vraa : errorHandle
* rsession should never be NULL here. * rsession may be NULL if session is being created
**/ * in parallel by another thread.
ss_dassert(rsession != NULL); */
while(session->router_session == NULL)
{
usleep(1);
}
rsession = session->router_session;
LOGIF(LD, (skygw_log_write_flush( LOGIF(LD, (skygw_log_write_flush(
LOGFILE_DEBUG, LOGFILE_DEBUG,
@ -792,12 +796,18 @@ static int backend_write_delayqueue(DCB *dcb)
if (rc == 0) { if (rc == 0) {
/*< vraa : errorHandle */ /*< vraa : errorHandle */
/**
* This error can be muted because it is often due
* unexpected dcb state which means that concurrent thread
* already wrote the queue and closed dcb.
*/
#if 0
LOGIF(LE, (skygw_log_write_flush( LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR, LOGFILE_ERROR,
"%lu [backend_write_delayqueue] Some error occurred in " "%lu [backend_write_delayqueue] Some error occurred in "
"backend.", "backend.",
pthread_self()))); pthread_self())));
#endif
mysql_send_custom_error( mysql_send_custom_error(
dcb->session->client, dcb->session->client,
1, 1,

View File

@ -362,7 +362,7 @@ int gw_receive_backend_auth(
{ {
ss_dassert(n < 0 && head == NULL); ss_dassert(n < 0 && head == NULL);
rc = -1; rc = -1;
LOGIF(LD, (skygw_log_write( LOGIF(LD, (skygw_log_write_flush(
LOGFILE_DEBUG, LOGFILE_DEBUG,
"%lu [gw_receive_backend_auth] Reading from backend dcb %p " "%lu [gw_receive_backend_auth] Reading from backend dcb %p "
"fd %d in state %s failed. n %d, head %p, len %d", "fd %d in state %s failed. n %d, head %p, len %d",