Skip to content

Commit fb6b556

Browse files
committed
Fix memory leak problems
1 parent 103cb05 commit fb6b556

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

tc_mysql_module.c

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,32 @@ proc_when_sess_created(tc_sess_t *s)
245245
return TC_OK;
246246
}
247247

248+
static int
249+
proc_when_sess_destroyed(tc_sess_t *s)
250+
{
251+
link_list *list;
252+
p_link_node ln, tln;
253+
mysql_table_item_t *item;
254+
255+
item = hash_find(ctx.table, s->hash_key);
256+
if (item != NULL) {
257+
list = item->list;
258+
ln = link_list_first(list);
259+
while (ln) {
260+
tln = ln;
261+
ln = link_list_get_next(list, ln);
262+
link_list_remove(list, tln);
263+
tc_pfree(ctx.pool, tln->data);
264+
tc_pfree(ctx.pool, tln);
265+
}
266+
267+
tc_pfree(ctx.pool, list);
268+
269+
hash_del(ctx.table, ctx.pool, s->hash_key);
270+
}
271+
272+
return TC_OK;
273+
}
248274

249275
static int
250276
proc_auth(tc_sess_t *s, tc_iph_t *ip, tc_tcph_t *tcp)
@@ -323,7 +349,7 @@ tc_module_t tc_mysql_module = {
323349
prepare_for_renew_session,
324350
check_pack_needed_for_recons,
325351
proc_when_sess_created,
326-
NULL,
352+
proc_when_sess_destroyed,
327353
NULL,
328354
proc_auth,
329355
NULL,

0 commit comments

Comments
 (0)