[MEDIUM] Fix memory freeing at exit
New functions implemented:
- deinit_pollers: called at the end of deinit())
- prune_acl: called via list_for_each_entry_safe
Add missing pool_destroy2 calls:
- p->hdr_idx_pool
- pool2_tree64
Implement all task stopping:
- health-check: needs new "struct task" in the struct server
- queue processing: queue_mgt
- appsess_refresh: appsession_refresh
before (idle system):
==6079== LEAK SUMMARY:
==6079== definitely lost: 1,112 bytes in 75 blocks.
==6079== indirectly lost: 53,356 bytes in 2,090 blocks.
==6079== possibly lost: 52 bytes in 1 blocks.
==6079== still reachable: 150,996 bytes in 504 blocks.
==6079== suppressed: 0 bytes in 0 blocks.
after (idle system):
==6945== LEAK SUMMARY:
==6945== definitely lost: 7,644 bytes in 137 blocks.
==6945== indirectly lost: 9,913 bytes in 587 blocks.
==6945== possibly lost: 0 bytes in 0 blocks.
==6945== still reachable: 0 bytes in 0 blocks.
==6945== suppressed: 0 bytes in 0 blocks.
before (running system for ~2m):
==9343== LEAK SUMMARY:
==9343== definitely lost: 1,112 bytes in 75 blocks.
==9343== indirectly lost: 54,199 bytes in 2,122 blocks.
==9343== possibly lost: 52 bytes in 1 blocks.
==9343== still reachable: 151,128 bytes in 509 blocks.
==9343== suppressed: 0 bytes in 0 blocks.
after (running system for ~2m):
==11616== LEAK SUMMARY:
==11616== definitely lost: 7,644 bytes in 137 blocks.
==11616== indirectly lost: 9,981 bytes in 591 blocks.
==11616== possibly lost: 0 bytes in 0 blocks.
==11616== still reachable: 4 bytes in 1 blocks.
==11616== suppressed: 0 bytes in 0 blocks.
Still not perfect but significant improvement.
diff --git a/src/appsession.c b/src/appsession.c
index 9b6868c..e1a01cc 100644
--- a/src/appsession.c
+++ b/src/appsession.c
@@ -27,7 +27,7 @@
#include <proto/task.h>
-
+static struct task *appsess_refresh = NULL;
struct pool_head *pool2_appsess;
struct app_pool apools;
int have_appsession;
@@ -87,17 +87,17 @@
int appsession_task_init(void)
{
static int initialized = 0;
- struct task *t;
if (!initialized) {
- if ((t = pool_alloc2(pool2_task)) == NULL)
+ if ((appsess_refresh = pool_alloc2(pool2_task)) == NULL)
return -1;
- t->wq = NULL;
- t->qlist.p = NULL;
- t->state = TASK_IDLE;
- t->context = NULL;
- tv_ms_add(&t->expire, &now, TBLCHKINT);
- t->process = appsession_refresh;
- task_queue(t);
+
+ appsess_refresh->wq = NULL;
+ appsess_refresh->qlist.p = NULL;
+ appsess_refresh->state = TASK_IDLE;
+ appsess_refresh->context = NULL;
+ tv_ms_add(&appsess_refresh->expire, &now, TBLCHKINT);
+ appsess_refresh->process = appsession_refresh;
+ task_queue(appsess_refresh);
initialized ++;
}
return 0;
@@ -168,6 +168,13 @@
appsession_hash_destroy(&(p->htbl_proxy));
p = p->next;
}
+
+ if (appsess_refresh) {
+ task_delete(appsess_refresh);
+ task_free(appsess_refresh);
+ appsess_refresh = NULL;
+ }
+
}/* end appsession_cleanup() */