Fix crash on NULL client DCB in mysql_backend.c

It is possible that a session is in the dummy state (a transient state)
when a backend write occurs. The check for the client protocol NULL-ness
should extend to the client DCB itself.
This commit is contained in:
Markus Makela
2016-12-12 22:02:12 +02:00
parent 101fc82fa0
commit a66c8fb919

View File

@ -1055,8 +1055,11 @@ static int gw_MySQLWrite_backend(DCB *dcb, GWBUF *queue)
mysql_server_cmd_t cmd = MYSQL_GET_COMMAND(ptr); mysql_server_cmd_t cmd = MYSQL_GET_COMMAND(ptr);
/** Copy the current command being executed to this backend */ /** Copy the current command being executed to this backend */
if (dcb->session->client_dcb && dcb->session->client_dcb->protocol)
{
MySQLProtocol *client_proto = (MySQLProtocol*)dcb->session->client_dcb->protocol; MySQLProtocol *client_proto = (MySQLProtocol*)dcb->session->client_dcb->protocol;
backend_protocol->current_command = client_proto ? client_proto->current_command : -1; backend_protocol->current_command = client_proto->current_command;
}
MXS_DEBUG("%lu [gw_MySQLWrite_backend] write to dcb %p " MXS_DEBUG("%lu [gw_MySQLWrite_backend] write to dcb %p "
"fd %d protocol state %s.", "fd %d protocol state %s.",