Always stop the session by closing the client DCB
By always starting the session shutdown process by stopping the client DCB, the manipulation of the session state can be removed from the backend protocol modules and replaced with a fake hangup event. Delivering this event via the core allows the actual dcb_close call on the client DCB to be done only when the client DCB is being handled by a worker.
This commit is contained in:
@ -319,11 +319,8 @@ session_simple_free(MXS_SESSION *session, DCB *dcb)
|
||||
void session_close(MXS_SESSION *session)
|
||||
{
|
||||
if (session->router_session)
|
||||
{
|
||||
if (session->state != SESSION_STATE_STOPPING)
|
||||
{
|
||||
session->state = SESSION_STATE_STOPPING;
|
||||
}
|
||||
|
||||
MXS_ROUTER_OBJECT* router = session->service->router;
|
||||
MXS_ROUTER* router_instance = session->service->router_instance;
|
||||
|
@ -583,7 +583,7 @@ static void do_handle_error(DCB *dcb, mxs_error_action_t action, const char *err
|
||||
*/
|
||||
if (!succp)
|
||||
{
|
||||
session->state = SESSION_STATE_STOPPING;
|
||||
poll_fake_hangup_event(session->client_dcb);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1401,29 +1401,20 @@ static int gw_client_close(DCB *dcb)
|
||||
*/
|
||||
static int gw_client_hangup_event(DCB *dcb)
|
||||
{
|
||||
MXS_SESSION* session;
|
||||
|
||||
CHK_DCB(dcb);
|
||||
session = dcb->session;
|
||||
MXS_SESSION* session = dcb->session;
|
||||
|
||||
if (session != NULL && session->state == SESSION_STATE_ROUTER_READY)
|
||||
if (session)
|
||||
{
|
||||
CHK_SESSION(session);
|
||||
}
|
||||
|
||||
if (session != NULL && session->state == SESSION_STATE_STOPPING)
|
||||
{
|
||||
goto retblock;
|
||||
}
|
||||
|
||||
if (session->state != SESSION_STATE_DUMMY && !session_valid_for_pool(session))
|
||||
{
|
||||
// The client did not send a COM_QUIT packet
|
||||
modutil_send_mysql_err_packet(dcb, 0, 0, 1927, "08S01", "Connection killed by MaxScale");
|
||||
}
|
||||
dcb_close(dcb);
|
||||
}
|
||||
|
||||
retblock:
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user