diff --git a/server/core/buffer.cc b/server/core/buffer.cc index f49e95653..f870c838d 100644 --- a/server/core/buffer.cc +++ b/server/core/buffer.cc @@ -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) diff --git a/server/core/modutil.cc b/server/core/modutil.cc index 527e64ae7..ad1bdde80 100644 --- a/server/core/modutil.cc +++ b/server/core/modutil.cc @@ -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; } diff --git a/server/modules/protocol/MySQL/mariadbclient/mysql_client.cc b/server/modules/protocol/MySQL/mariadbclient/mysql_client.cc index e633939ed..915b37d71 100644 --- a/server/modules/protocol/MySQL/mariadbclient/mysql_client.cc +++ b/server/modules/protocol/MySQL/mariadbclient/mysql_client.cc @@ -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;