From b3ddcd0dbb6cf0db09f7bd156d73b3cb8e284e2d Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 27 Aug 2021 14:58:46 +0200 Subject: -fix misc. memory leaks --- src/backend/anastasis-httpd.c | 10 ++++++++++ src/backend/anastasis-httpd.h | 5 +++++ src/backend/anastasis-httpd_truth.c | 22 ++++++---------------- 3 files changed, 21 insertions(+), 16 deletions(-) (limited to 'src/backend') diff --git a/src/backend/anastasis-httpd.c b/src/backend/anastasis-httpd.c index 35a4d9c..fdf17ff 100644 --- a/src/backend/anastasis-httpd.c +++ b/src/backend/anastasis-httpd.c @@ -111,6 +111,11 @@ static int AH_connection_close; */ static struct GNUNET_SCHEDULER_Task *mhd_task; +/** + * Heap for processing timeouts of requests. + */ +struct GNUNET_CONTAINER_Heap *AH_to_heap; + /** * Global return code */ @@ -496,6 +501,11 @@ do_shutdown (void *cls) ANASTASIS_DB_plugin_unload (db); db = NULL; } + if (NULL != AH_to_heap) + { + GNUNET_CONTAINER_heap_destroy (AH_to_heap); + AH_to_heap = NULL; + } } diff --git a/src/backend/anastasis-httpd.h b/src/backend/anastasis-httpd.h index b84088d..33e0504 100644 --- a/src/backend/anastasis-httpd.h +++ b/src/backend/anastasis-httpd.h @@ -179,6 +179,11 @@ extern char *AH_backend_url; */ extern char *AH_currency; +/** + * Heap for processing timeouts of requests. + */ +extern struct GNUNET_CONTAINER_Heap *AH_to_heap; + /** * Our configuration. */ diff --git a/src/backend/anastasis-httpd_truth.c b/src/backend/anastasis-httpd_truth.c index aa3011b..df105dd 100644 --- a/src/backend/anastasis-httpd_truth.c +++ b/src/backend/anastasis-httpd_truth.c @@ -229,11 +229,6 @@ static struct GetContext *gc_head; */ static struct GetContext *gc_tail; -/** - * Heap for processing timeouts of requests. - */ -static struct GNUNET_CONTAINER_Heap *to_heap; - /** * Task running #do_timeout(). */ @@ -253,7 +248,7 @@ do_timeout (void *cls) (void) cls; to_task = NULL; while (NULL != - (gc = GNUNET_CONTAINER_heap_peek (to_heap))) + (gc = GNUNET_CONTAINER_heap_peek (AH_to_heap))) { if (GNUNET_TIME_absolute_is_future (gc->timeout)) break; @@ -269,7 +264,7 @@ do_timeout (void *cls) GNUNET_assert (NULL != gc->hn); gc->hn = NULL; GNUNET_assert (gc == - GNUNET_CONTAINER_heap_remove_root (to_heap)); + GNUNET_CONTAINER_heap_remove_root (AH_to_heap)); } if (NULL == gc) return; @@ -336,11 +331,6 @@ AH_truth_shutdown (void) GNUNET_SCHEDULER_cancel (to_task); to_task = NULL; } - if (NULL != to_heap) - { - GNUNET_CONTAINER_heap_destroy (to_heap); - to_heap = NULL; - } } @@ -931,10 +921,10 @@ run_authorization_process (struct MHD_Connection *connection, return MHD_YES; case ANASTASIS_AUTHORIZATION_RES_SUSPENDED: /* connection was suspended */ - if (NULL == to_heap) - to_heap = GNUNET_CONTAINER_heap_create ( + if (NULL == AH_to_heap) + AH_to_heap = GNUNET_CONTAINER_heap_create ( GNUNET_CONTAINER_HEAP_ORDER_MIN); - gc->hn = GNUNET_CONTAINER_heap_insert (to_heap, + gc->hn = GNUNET_CONTAINER_heap_insert (AH_to_heap, gc, gc->timeout.abs_value_us); gc->suspended = true; @@ -946,7 +936,7 @@ run_authorization_process (struct MHD_Connection *connection, { struct GetContext *rn; - rn = GNUNET_CONTAINER_heap_peek (to_heap); + rn = GNUNET_CONTAINER_heap_peek (AH_to_heap); to_task = GNUNET_SCHEDULER_add_at (rn->timeout, &do_timeout, NULL); -- cgit v1.2.3