Fix readconnroute debug assertion

If the DCB is closed in handleError, it would be NULL in closeSession. To
only close the DCB in one place, the handleError can be reduced to writing
an error to the client and marking the failure as a fatal one.
This commit is contained in:
Markus Mäkelä
2018-10-01 23:23:48 +03:00
parent 4216ffa384
commit ea971a664e

View File

@ -475,12 +475,8 @@ static void closeSession(MXS_ROUTER* instance, MXS_ROUTER_SESSION* router_sessio
{
ROUTER_CLIENT_SES* router_cli_ses = (ROUTER_CLIENT_SES*) router_session;
mxb_assert(router_cli_ses->backend_dcb);
if (router_cli_ses->backend_dcb)
{
dcb_close(router_cli_ses->backend_dcb);
}
}
/** Log routing failure due to closed session */
static void log_closed_session(mxs_mysql_cmd_t mysql_command, SERVER_REF* ref)
@ -715,26 +711,11 @@ static void handleError(MXS_ROUTER* instance,
{
mxb_assert(problem_dcb->dcb_role == DCB_ROLE_BACKEND_HANDLER);
DCB* client_dcb;
MXS_SESSION* session = problem_dcb->session;
mxs_session_state_t sesstate;
ROUTER_CLIENT_SES* router_cli_ses = (ROUTER_CLIENT_SES*) router_session;
sesstate = session->state;
client_dcb = session->client_dcb;
if (sesstate == SESSION_STATE_ROUTER_READY)
{
mxb_assert(problem_dcb->session->state == SESSION_STATE_ROUTER_READY);
DCB* client_dcb = problem_dcb->session->client_dcb;
client_dcb->func.write(client_dcb, gwbuf_clone(errbuf));
}
if (router_cli_ses && problem_dcb == router_cli_ses->backend_dcb)
{
router_cli_ses->backend_dcb = NULL;
dcb_close(problem_dcb);
}
/** false because connection is not available anymore */
// The DCB will be closed once the session closes, no need to close it here
*succp = false;
}