MXS-619: Allow backend authentication to complete
By deferring the closing of a DCB until the protocol tells that it's in a stable state, we avoid closing the connection mid-authentication. This makes sure that all connections have reached a stable state before they are closed which in turn prevents the connections from counting towards aborted connects (or failed authentications like it did with the old fix).
This commit is contained in:
@ -63,6 +63,7 @@ static bool get_ip_string_and_port(struct sockaddr_storage* sa,
|
||||
int iplen,
|
||||
in_port_t* port_out);
|
||||
static bool gw_connection_established(DCB* dcb);
|
||||
static bool gw_auth_is_complete(DCB* dcb);
|
||||
json_t* gw_json_diagnostics(DCB* dcb);
|
||||
|
||||
extern "C"
|
||||
@ -92,6 +93,8 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
NULL, /* Connection limit reached */
|
||||
gw_connection_established,
|
||||
gw_json_diagnostics,
|
||||
NULL,
|
||||
gw_auth_is_complete,
|
||||
};
|
||||
|
||||
static MXS_MODULE info =
|
||||
@ -2018,6 +2021,24 @@ static bool gw_connection_established(DCB* dcb)
|
||||
&& !proto->stored_query;
|
||||
}
|
||||
|
||||
static bool gw_auth_is_complete(DCB* dcb)
|
||||
{
|
||||
MySQLProtocol* proto = (MySQLProtocol*)dcb->protocol;
|
||||
|
||||
switch (proto->protocol_auth_state)
|
||||
{
|
||||
case MXS_AUTH_STATE_FAILED:
|
||||
case MXS_AUTH_STATE_HANDSHAKE_FAILED:
|
||||
case MXS_AUTH_STATE_COMPLETE:
|
||||
MXS_DEBUG("(%lu) Auth is complete for DCB %lu", dcb->session->ses_id, dcb->m_uid);
|
||||
return true;
|
||||
|
||||
default:
|
||||
MXS_DEBUG("(%lu) Auth not yet complete for DCB %lu", dcb->session->ses_id, dcb->m_uid);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
json_t* gw_json_diagnostics(DCB* dcb)
|
||||
{
|
||||
MySQLProtocol* proto = static_cast<MySQLProtocol*>(dcb->protocol);
|
||||
|
Reference in New Issue
Block a user