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:
parent
d68f20b75b
commit
bbe4f42935
@ -795,6 +795,7 @@ gwbuf_make_contiguous(GWBUF *orig)
|
||||
|
||||
if (orig == NULL)
|
||||
{
|
||||
ss_info_dassert(!true, "gwbuf_make_contiguous: NULL buffer");
|
||||
return NULL;
|
||||
}
|
||||
if (orig->next == NULL)
|
||||
|
@ -485,6 +485,17 @@ int modutil_send_mysql_err_packet(DCB *dcb,
|
||||
return dcb->func.write(dcb, buf);
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the first packet from a buffer.
|
||||
*
|
||||
@ -531,6 +542,7 @@ GWBUF* modutil_get_next_MySQL_packet(GWBUF** p_readbuf)
|
||||
}
|
||||
}
|
||||
|
||||
ss_dassert(!packet || only_one_packet(packet));
|
||||
return packet;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user