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,
gwbuf_length(dcb->delayq));
}
rsession = session->router_session;
ss_dassert(rsession != NULL);
/*<
ss_dassert(session->state == SESSION_READY);
/**
* vraa : errorHandle
* rsession should never be NULL here.
**/
ss_dassert(rsession != NULL);
* rsession may be NULL if session is being created
* in parallel by another thread.
*/
while(session->router_session == NULL)
{
usleep(1);
}
rsession = session->router_session;
LOGIF(LD, (skygw_log_write_flush(
LOGFILE_DEBUG,
@ -792,12 +796,18 @@ static int backend_write_delayqueue(DCB *dcb)
if (rc == 0) {
/*< 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(
LOGFILE_ERROR,
"%lu [backend_write_delayqueue] Some error occurred in "
"backend.",
pthread_self())));
#endif
mysql_send_custom_error(
dcb->session->client,
1,

View File

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