Add more packet splitting debug assertions

Having more debug assertions in functions that split packets guarantees
that they work as expected.
This commit is contained in:
Markus Mäkelä
2018-07-20 11:16:39 +03:00
parent d68f20b75b
commit bbe4f42935
3 changed files with 13 additions and 12 deletions

View File

@ -1576,17 +1576,6 @@ static bool reauthenticate_client(MXS_SESSION* session, GWBUF* packetbuf)
return rval;
}
// Helper function for debug assertions
static bool only_one_packet(GWBUF* buffer)
{
ss_dassert(buffer);
uint8_t header[4] = {};
gwbuf_copy_data(buffer, 0, MYSQL_HEADER_LEN, header);
size_t packet_len = gw_mysql_get_byte3(header);
size_t buffer_len = gwbuf_length(buffer);
return packet_len + MYSQL_HEADER_LEN == buffer_len;
}
/**
* Detect if buffer includes partial mysql packet or multiple packets.
* Store partial packet to dcb_readqueue. Send complete packets one by one
@ -1616,7 +1605,6 @@ static int route_by_statement(MXS_SESSION* session, uint64_t capabilities, GWBUF
if (packetbuf != NULL)
{
ss_dassert(only_one_packet(packetbuf));
CHK_GWBUF(packetbuf);
MySQLProtocol* proto = (MySQLProtocol*)session->client_dcb->protocol;