@@ -30,6 +30,7 @@ typedef struct {
30
30
31
31
static tc_mysql_ctx_t ctx ;
32
32
33
+
33
34
static int
34
35
init_mysql_module ()
35
36
{
@@ -49,6 +50,35 @@ init_mysql_module()
49
50
}
50
51
51
52
53
+ static int
54
+ release_resources (uint64_t key )
55
+ {
56
+ link_list * list ;
57
+ p_link_node ln , tln ;
58
+ mysql_table_item_t * item ;
59
+
60
+ item = hash_find (ctx .table , key );
61
+ if (item != NULL ) {
62
+ list = item -> list ;
63
+ ln = link_list_first (list );
64
+ while (ln ) {
65
+ tln = ln ;
66
+ ln = link_list_get_next (list , ln );
67
+ link_list_remove (list , tln );
68
+ tc_pfree (ctx .pool , tln -> data );
69
+ tc_pfree (ctx .pool , tln );
70
+ }
71
+
72
+ tc_pfree (ctx .pool , item );
73
+ tc_pfree (ctx .pool , list );
74
+
75
+ hash_del (ctx .table , ctx .pool , key );
76
+ }
77
+
78
+ return TC_OK ;
79
+ }
80
+
81
+
52
82
static void
53
83
remove_obsolete_resources (int is_full )
54
84
{
@@ -76,11 +106,7 @@ remove_obsolete_resources(int is_full)
76
106
hn = (hash_node * ) ln -> data ;
77
107
next_ln = link_list_get_next (l , ln );
78
108
if (hn -> access_time < thresh_access_tme ) {
79
- ctx .table -> total -- ;
80
- link_list_remove (l , ln );
81
- tc_pfree (ctx .pool , hn -> data );
82
- tc_pfree (ctx .pool , ln -> data );
83
- tc_pfree (ctx .pool , ln );
109
+ release_resources (hn -> key );
84
110
}
85
111
ln = next_ln ;
86
112
}
@@ -297,38 +323,17 @@ proc_when_sess_created(tc_sess_t *s)
297
323
return TC_OK ;
298
324
}
299
325
326
+
300
327
static int
301
328
proc_when_sess_destroyed (tc_sess_t * s )
302
329
{
303
- link_list * list ;
304
- p_link_node ln , tln ;
305
- mysql_table_item_t * item ;
306
-
307
- item = hash_find (ctx .table , s -> hash_key );
308
- if (item != NULL ) {
309
- list = item -> list ;
310
- ln = link_list_first (list );
311
- while (ln ) {
312
- tln = ln ;
313
- ln = link_list_get_next (list , ln );
314
- link_list_remove (list , tln );
315
- tc_pfree (ctx .pool , tln -> data );
316
- tc_pfree (ctx .pool , tln );
317
- }
318
-
319
- tc_pfree (ctx .pool , item );
320
- tc_pfree (ctx .pool , list );
321
-
322
- hash_del (ctx .table , ctx .pool , s -> hash_key );
323
- }
324
-
330
+ release_resources (s -> hash_key );
325
331
return TC_OK ;
326
332
}
327
333
328
334
static int
329
335
proc_auth (tc_sess_t * s , tc_iph_t * ip , tc_tcph_t * tcp )
330
336
{
331
- bool is_need_omit ;
332
337
uint16_t size_tcp ;
333
338
unsigned char * p , * payload , pack_number ;
334
339
tc_mysql_session * mysql_sess ;
@@ -339,7 +344,6 @@ proc_auth(tc_sess_t *s, tc_iph_t *ip, tc_tcph_t *tcp)
339
344
340
345
if (!s -> sm .fake_syn ) {
341
346
342
- is_need_omit = false;
343
347
mysql_sess = s -> data ;
344
348
345
349
if (!mysql_sess -> req_begin ) {
@@ -355,7 +359,6 @@ proc_auth(tc_sess_t *s, tc_iph_t *ip, tc_tcph_t *tcp)
355
359
356
360
} else if (pack_number == (unsigned char ) SEC_AUTH_PACKET_NUM ) {
357
361
/* if it is the second authenticate_user, skip it */
358
- is_need_omit = true;
359
362
tc_log_debug0 (LOG_NOTICE , 0 , "omit sec validation for mysql" );
360
363
mysql_sess -> req_begin = 1 ;
361
364
mysql_sess -> seq_diff = s -> cur_pack .cont_len ;
0 commit comments