dcb.c:dcb_write accept also dcb state DCB_STATE_NOPOLLING since it only means that dcb has been removed from epoll set but it is still possible to write to it. Bug #384 http://bugs.skysql.com/show_bug.cgi?id=384 session.h:added new state for SESSION, SESSION_STATE_ROUTER_READY which follows SESSION_STATE_READY. The difference is that ROUTER_READY is set only after router session is successfully created while READY means that session still lacks router. session.c:set SESSION_STATE_ROUTER_READY when router is created. mysql_backend.c:gw_read_backend_event, added SESSION_STATE_ROUTER_READY check before router session is closed. Changed chec kso that it doesn't block in infinite loop (although it shouldn't be possible anyway). mysql_backend.c:gw_error_backend_event, added similar check before session is closed.
This commit is contained in:
@ -299,18 +299,32 @@ static int gw_read_backend_event(DCB *dcb) {
|
||||
dcb->delayq,
|
||||
gwbuf_length(dcb->delayq));
|
||||
}
|
||||
ss_dassert(session->state == SESSION_READY);
|
||||
/**
|
||||
* vraa : errorHandle
|
||||
* rsession may be NULL if session is being created
|
||||
* in parallel by another thread.
|
||||
*/
|
||||
while(session->router_session == NULL)
|
||||
{
|
||||
|
||||
while (session->state != SESSION_STATE_ROUTER_READY)
|
||||
{
|
||||
ss_dassert(
|
||||
session->state == SESSION_STATE_READY ||
|
||||
session->state ==
|
||||
SESSION_STATE_ROUTER_READY);
|
||||
/**
|
||||
* Session shouldn't be NULL at this point
|
||||
* anymore. Just checking..
|
||||
*/
|
||||
if (session->client->session == NULL)
|
||||
{
|
||||
rc = 1;
|
||||
goto return_with_lock;
|
||||
}
|
||||
usleep(1);
|
||||
}
|
||||
/**
|
||||
* rsession shouldn't be NULL since session
|
||||
* state indicates that it was initialized
|
||||
* successfully.
|
||||
*/
|
||||
rsession = session->router_session;
|
||||
|
||||
ss_dassert(rsession != NULL);
|
||||
|
||||
LOGIF(LD, (skygw_log_write_flush(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [gw_read_backend_event] "
|
||||
@ -596,26 +610,28 @@ static int gw_error_backend_event(DCB *dcb) {
|
||||
rc = 1;
|
||||
}
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [gw_error_backend_event] Some error occurred in backend. "
|
||||
"rc = %d",
|
||||
pthread_self(),
|
||||
rc)));
|
||||
rsession = session->router_session;
|
||||
ss_dassert(rsession != NULL);
|
||||
/*<
|
||||
* vraa : errorHandle
|
||||
* rsession should never be NULL here.
|
||||
*/
|
||||
LOGIF(LD, (skygw_log_write_flush(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [gw_error_backend_event] "
|
||||
"Call closeSession for backend "
|
||||
"session.",
|
||||
pthread_self())));
|
||||
|
||||
router->closeSession(router_instance, rsession);
|
||||
|
||||
|
||||
if (session->state == SESSION_STATE_ROUTER_READY)
|
||||
{
|
||||
rsession = session->router_session;
|
||||
/*<
|
||||
* rsession should never be NULL here.
|
||||
*/
|
||||
ss_dassert(rsession != NULL);
|
||||
LOGIF(LD, (skygw_log_write_flush(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [gw_error_backend_event] "
|
||||
"Call closeSession for backend "
|
||||
"session.",
|
||||
pthread_self())));
|
||||
|
||||
router->closeSession(router_instance, rsession);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user