Process backend packets only once

When the router requires statement based output, the gathering of complete
packets can be skipped as the process of splitting the complete packets
into individual packets implies that only complete packets are handled.

Also added a quicker check for stored protocol commands than a call to
protocol_get_srv_command.
This commit is contained in:
Markus Mäkelä
2017-10-08 23:15:18 +03:00
parent d97742bf66
commit c5ff130b33

View File

@ -745,7 +745,8 @@ gw_read_and_write(DCB *dcb)
bool result_collected = false;
MySQLProtocol *proto = (MySQLProtocol *)dcb->protocol;
if (rcap_type_required(capabilities, RCAP_TYPE_STMT_OUTPUT) || (proto->ignore_replies != 0))
if (rcap_type_required(capabilities, RCAP_TYPE_CONTIGUOUS_OUTPUT) ||
proto->collect_result || proto->ignore_replies != 0)
{
GWBUF *tmp = modutil_get_complete_packets(&read_buffer);
/* Put any residue into the read queue */
@ -760,10 +761,6 @@ gw_read_and_write(DCB *dcb)
read_buffer = tmp;
if (rcap_type_required(capabilities, RCAP_TYPE_CONTIGUOUS_OUTPUT) ||
proto->collect_result ||
proto->ignore_replies != 0)
{
if ((tmp = gwbuf_make_contiguous(read_buffer)))
{
read_buffer = tmp;
@ -809,7 +806,6 @@ gw_read_and_write(DCB *dcb)
}
}
}
}
if (proto->ignore_replies > 0)
{
@ -909,7 +905,8 @@ gw_read_and_write(DCB *dcb)
* If protocol has session command set, concatenate whole
* response into one buffer.
*/
if (protocol_get_srv_command((MySQLProtocol *)dcb->protocol, true) != MXS_COM_UNDEFINED)
if (proto->protocol_command.scom_cmd != MXS_COM_UNDEFINED &&
protocol_get_srv_command(proto, true) != MXS_COM_UNDEFINED)
{
if (result_collected)
{
@ -943,8 +940,8 @@ gw_read_and_write(DCB *dcb)
!rcap_type_required(capabilities, RCAP_TYPE_RESULTSET_OUTPUT) &&
!result_collected)
{
stmt = modutil_get_next_MySQL_packet(&read_buffer);
if ((stmt = modutil_get_next_MySQL_packet(&read_buffer)))
{
if (!GWBUF_IS_CONTIGUOUS(stmt))
{
// Make sure the buffer is contiguous
@ -952,6 +949,17 @@ gw_read_and_write(DCB *dcb)
}
}
else
{
// All complete packets are processed, store partial packets for later use
if (read_buffer)
{
dcb_readq_prepend(dcb, read_buffer);
}
return return_code;
}
}
else
{
stmt = read_buffer;
read_buffer = NULL;