@@ -30,6 +30,7 @@ typedef struct {
3030
3131static tc_mysql_ctx_t ctx ;
3232
33+
3334static int
3435init_mysql_module ()
3536{
@@ -49,6 +50,35 @@ init_mysql_module()
4950}
5051
5152
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+
5282static void
5383remove_obsolete_resources (int is_full )
5484{
@@ -76,11 +106,7 @@ remove_obsolete_resources(int is_full)
76106 hn = (hash_node * ) ln -> data ;
77107 next_ln = link_list_get_next (l , ln );
78108 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 );
84110 }
85111 ln = next_ln ;
86112 }
@@ -297,38 +323,17 @@ proc_when_sess_created(tc_sess_t *s)
297323 return TC_OK ;
298324}
299325
326+
300327static int
301328proc_when_sess_destroyed (tc_sess_t * s )
302329{
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 );
325331 return TC_OK ;
326332}
327333
328334static int
329335proc_auth (tc_sess_t * s , tc_iph_t * ip , tc_tcph_t * tcp )
330336{
331- bool is_need_omit ;
332337 uint16_t size_tcp ;
333338 unsigned char * p , * payload , pack_number ;
334339 tc_mysql_session * mysql_sess ;
@@ -339,7 +344,6 @@ proc_auth(tc_sess_t *s, tc_iph_t *ip, tc_tcph_t *tcp)
339344
340345 if (!s -> sm .fake_syn ) {
341346
342- is_need_omit = false;
343347 mysql_sess = s -> data ;
344348
345349 if (!mysql_sess -> req_begin ) {
@@ -355,7 +359,6 @@ proc_auth(tc_sess_t *s, tc_iph_t *ip, tc_tcph_t *tcp)
355359
356360 } else if (pack_number == (unsigned char ) SEC_AUTH_PACKET_NUM ) {
357361 /* if it is the second authenticate_user, skip it */
358- is_need_omit = true;
359362 tc_log_debug0 (LOG_NOTICE , 0 , "omit sec validation for mysql" );
360363 mysql_sess -> req_begin = 1 ;
361364 mysql_sess -> seq_diff = s -> cur_pack .cont_len ;
0 commit comments