Skip to content

Commit 21c026e

Browse files
committed
fix some assert and log
1 parent 279731b commit 21c026e

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

hash.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include "hash.h"
1212
#include "log.h"
1313

14-
#define INITIAL_HASH_SZ 2053
14+
#define INITIAL_HASH_SZ 16427
1515
#define MAX_LOAD_PERCENT 65
1616
#define SQL_MAX_LEN 2048
1717
#define VALUE_MAX_LEN 1024

packet.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ inbound(MysqlPcap *mp, char* data, uint32 datalen,
559559
lport, rport, 0, AfterBigExeutePacket);
560560
return ERR;
561561
}
562-
ASSERT(stmt_id >= 0);
562+
ASSERT(stmt_id > 0);
563563

564564
/* is param_count(must), param_type(possible) saved ?*/
565565
hash_get_param_count(mp->hash, dst, src,
@@ -958,7 +958,7 @@ outbound(MysqlPcap *mp, char *data, uint32 datalen,
958958
*/
959959
ret = parse_prepare_ok(data, datalen, &stmt_id, &param_count);
960960
if (ret == 0) {
961-
ASSERT(stmt_id >= 0);
961+
ASSERT(stmt_id > 0);
962962
ASSERT(param_count >= 0);
963963
ASSERT(2000 > param_count);
964964
hash_set_param_count(mp->hash, src, dst,

protocol.c

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ int isCompressPacket(char *payload, uint32 payload_len, int status)
3636

3737
if (payload_len < 5) {
3838
dump(L_ERR, "what sql %u", payload_len);
39+
printLastPacketInfo(1);
3940
return BAD;
4041
}
4142
uchar c = payload[3];
@@ -48,6 +49,11 @@ int isCompressPacket(char *payload, uint32 payload_len, int status)
4849
}
4950

5051
uint32 packet_length = uint3korr(payload);
52+
if (packet_length == 0) {
53+
dump(L_ERR, "what sql %u", payload_len);
54+
printLastPacketInfo(1);
55+
return BAD;
56+
}
5157

5258
/*
5359
normal
@@ -237,10 +243,10 @@ parse_result(char* payload, uint32 payload_len,
237243
if (*lastPs == RESULT_STAGE) {
238244
ret = resultset_packet(newData, new_len, tempNum);
239245
} else if (*lastPs == FIELD_STAGE) {
240-
uchar c = newData[3];
246+
uchar c = newData[3];
241247
ret = field_packet(newData, new_len, tempNum);
242248
} else {
243-
uchar c = newData[3];
249+
uchar c = newData[3];
244250
ASSERT(*lastPs == EOF_STAGE);
245251
ret = eof_packet(newData, new_len);
246252
}
@@ -279,7 +285,6 @@ parse_result(char* payload, uint32 payload_len,
279285
if (header_packet_length > 0 && header_packet_length < 10) {
280286
ulong field_lcb_length = lcb_length(payload + 4);
281287
ulong field_number = net_field_length(payload + 4);
282-
ASSERT((field_lcb_length == 1) || (field_lcb_length == 2) || (field_lcb_length == 3));
283288
/*is def, seq must increment ?*/
284289
if ((header_packet_length == field_lcb_length) &&
285290
(field_lcb_length < 4) && (field_number < 500)) {
@@ -350,7 +355,7 @@ eof_packet(char* payload, uint32 payload_len)
350355
}
351356
}
352357
/* eof packet span two packet */
353-
dump(L_ERR, "eof span two packet %u", payload_len);
358+
dump(L_DEBUG, "eof span two packet %u", payload_len);
354359
ASSERT(payload_len < 10);
355360
ASSERT(*lastData == NULL);
356361
ASSERT(*lastDataSize == 0);
@@ -709,16 +714,16 @@ parse_param(char *payload, uint32 payload_len, int param_count,
709714
pos++;
710715

711716
/* if =1 use below param_type, else use input param_type */
712-
ASSERT((send_types_to_server == 1 ) || (send_types_to_server == 0));
717+
ASSERT((send_types_to_server == 1 ) || (send_types_to_server == 0));
713718
if (send_types_to_server == 1) {
714719
param_type = param_type_pos = payload + pos;
715720
pos = pos + 2 * param_count; /* each type 2 bytes */
716721
}
717-
if (!param_type) {
718-
dump(L_ERR, "why here3");
719-
printLastPacketInfo(10);
720-
return NULL;
721-
}
722+
if (!param_type) {
723+
dump(L_ERR, "why here3");
724+
printLastPacketInfo(10);
725+
return NULL;
726+
}
722727
int i = 0;
723728
short type;
724729
int length;

0 commit comments

Comments
 (0)