MXS-619: Send fake response for unconnected DCBs

This causes the connection failure to be counted as an authentication
failure instead of a connection error. The former never causes the host to
be blocked which effectively solves the problem for most cases. The only
case where this would not work is where the network buffer for a backend
DCB is full right after the connection is created.
This commit is contained in:
Markus Mäkelä 2019-12-19 13:22:10 +02:00
parent e725ebb7d0
commit 484ff06795
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19

View File

@ -1415,10 +1415,20 @@ static int gw_backend_hangup(DCB* dcb)
static int gw_backend_close(DCB* dcb)
{
mxb_assert(dcb->session);
MySQLProtocol* proto = (MySQLProtocol*)dcb->protocol;
if (proto->protocol_auth_state == MXS_AUTH_STATE_INIT
|| proto->protocol_auth_state == MXS_AUTH_STATE_PENDING_CONNECT
|| proto->protocol_auth_state == MXS_AUTH_STATE_CONNECTED)
{
MYSQL_session client;
gw_get_shared_session_auth_info(dcb->session->client_dcb, &client);
memset(proto->scramble, 0, sizeof(proto->scramble));
dcb_write(dcb, gw_generate_auth_response(&client, proto, false, false, 0));
}
/** Send COM_QUIT to the backend being closed */
GWBUF* quitbuf = mysql_create_com_quit(NULL, 0);
mysql_send_com_quit(dcb, 0, quitbuf);
dcb_write(dcb, mysql_create_com_quit(NULL, 0));
/** Free protocol data */
mysql_protocol_done(dcb);