@@ -34,7 +34,7 @@ static int
34
34
init_mysql_module ()
35
35
{
36
36
37
- ctx .pool = tc_create_pool (TC_DEFAULT_POOL_SIZE , 0 , 0 );
37
+ ctx .pool = tc_create_pool (TC_PLUGIN_POOL_SIZE , 0 , 0 );
38
38
39
39
if (ctx .pool ) {
40
40
@@ -49,9 +49,57 @@ init_mysql_module()
49
49
}
50
50
51
51
52
+ static void
53
+ remove_obsolete_resources (int is_full )
54
+ {
55
+ time_t thresh_access_tme ;
56
+ uint32_t i , cnt = 0 ;
57
+ link_list * l ;
58
+ hash_node * hn ;
59
+ p_link_node ln , next_ln ;
60
+
61
+ if (ctx .table == NULL || ctx .table -> total == 0 ) {
62
+ return ;
63
+ }
64
+
65
+ if (is_full ) {
66
+ thresh_access_tme = tc_time () + 1 ;
67
+ } else {
68
+ thresh_access_tme = tc_time () - MAX_IDLE_TIME ;
69
+ }
70
+
71
+ for (i = 0 ; i < ctx .table -> size ; i ++ ) {
72
+ l = get_link_list (ctx .table , i );
73
+ if (l -> size > 0 ) {
74
+ ln = link_list_first (l );
75
+ while (ln ) {
76
+ hn = (hash_node * ) ln -> data ;
77
+ next_ln = link_list_get_next (l , ln );
78
+ 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 );
84
+ }
85
+ ln = next_ln ;
86
+ }
87
+
88
+ cnt += l -> size ;
89
+
90
+ if (ctx .table -> total == cnt ) {
91
+ break ;
92
+ }
93
+ }
94
+ }
95
+ }
96
+
97
+
52
98
static void
53
99
exit_mysql_module ()
54
100
{
101
+ tc_log_info (LOG_INFO , 0 , "call exit_mysql_module" );
102
+ remove_obsolete_resources (1 );
55
103
if (ctx .pool != NULL ) {
56
104
tc_destroy_pool (ctx .pool );
57
105
ctx .table = NULL ;
@@ -268,6 +316,7 @@ proc_when_sess_destroyed(tc_sess_t *s)
268
316
tc_pfree (ctx .pool , tln );
269
317
}
270
318
319
+ tc_pfree (ctx .pool , item );
271
320
tc_pfree (ctx .pool , list );
272
321
273
322
hash_del (ctx .table , ctx .pool , s -> hash_key );
@@ -349,6 +398,7 @@ tc_module_t tc_mysql_module = {
349
398
NULL ,
350
399
init_mysql_module ,
351
400
exit_mysql_module ,
401
+ remove_obsolete_resources ,
352
402
check_renew_session ,
353
403
prepare_for_renew_session ,
354
404
check_pack_needed_for_recons ,
0 commit comments