diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-08-27 14:58:46 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-08-27 14:58:46 +0200 |
commit | b3ddcd0dbb6cf0db09f7bd156d73b3cb8e284e2d (patch) | |
tree | 3371c706be8e44e47c530a4d4b85fe38980630eb /src/backend | |
parent | e2f67e7bf9c3779720b9a61012a4d0c0c4b6e1d1 (diff) | |
download | anastasis-b3ddcd0dbb6cf0db09f7bd156d73b3cb8e284e2d.tar.gz anastasis-b3ddcd0dbb6cf0db09f7bd156d73b3cb8e284e2d.tar.bz2 anastasis-b3ddcd0dbb6cf0db09f7bd156d73b3cb8e284e2d.zip |
-fix misc. memory leaks
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/anastasis-httpd.c | 10 | ||||
-rw-r--r-- | src/backend/anastasis-httpd.h | 5 | ||||
-rw-r--r-- | src/backend/anastasis-httpd_truth.c | 22 |
3 files changed, 21 insertions, 16 deletions
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 @@ -112,6 +112,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 */ static int global_result; @@ -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 @@ -180,6 +180,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. */ extern const struct GNUNET_CONFIGURATION_Handle *AH_cfg; 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 @@ -230,11 +230,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(). */ static struct GNUNET_SCHEDULER_Task *to_task; @@ -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); |