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

@ -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->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);
}
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;
}