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:
Markus Mäkelä
2018-02-01 01:32:22 +02:00
parent ebf0d6fc5f
commit 9f0a691233
3 changed files with 10 additions and 22 deletions

View File

@ -319,11 +319,8 @@ session_simple_free(MXS_SESSION *session, DCB *dcb)
void session_close(MXS_SESSION *session) void session_close(MXS_SESSION *session)
{ {
if (session->router_session) if (session->router_session)
{
if (session->state != SESSION_STATE_STOPPING)
{ {
session->state = SESSION_STATE_STOPPING; session->state = SESSION_STATE_STOPPING;
}
MXS_ROUTER_OBJECT* router = session->service->router; MXS_ROUTER_OBJECT* router = session->service->router;
MXS_ROUTER* router_instance = session->service->router_instance; MXS_ROUTER* router_instance = session->service->router_instance;

View File

@ -583,7 +583,7 @@ static void do_handle_error(DCB *dcb, mxs_error_action_t action, const char *err
*/ */
if (!succp) if (!succp)
{ {
session->state = SESSION_STATE_STOPPING; poll_fake_hangup_event(session->client_dcb);
} }
} }

View File

@ -1401,29 +1401,20 @@ static int gw_client_close(DCB *dcb)
*/ */
static int gw_client_hangup_event(DCB *dcb) static int gw_client_hangup_event(DCB *dcb)
{ {
MXS_SESSION* session;
CHK_DCB(dcb); 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); CHK_SESSION(session);
}
if (session != NULL && session->state == SESSION_STATE_STOPPING)
{
goto retblock;
}
if (session->state != SESSION_STATE_DUMMY && !session_valid_for_pool(session)) if (session->state != SESSION_STATE_DUMMY && !session_valid_for_pool(session))
{ {
// The client did not send a COM_QUIT packet // The client did not send a COM_QUIT packet
modutil_send_mysql_err_packet(dcb, 0, 0, 1927, "08S01", "Connection killed by MaxScale"); modutil_send_mysql_err_packet(dcb, 0, 0, 1927, "08S01", "Connection killed by MaxScale");
} }
dcb_close(dcb); dcb_close(dcb);
}
retblock:
return 1; return 1;
} }