diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-01-06 16:00:32 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-01-06 16:00:32 +0000 |
commit | eec94c8f0a11902803983efe093e4b4de9359898 (patch) | |
tree | 5eb78c6a4a458d6832c8ba3029fb6cc1eeb1d636 /src/libstat/stat_config.c | |
parent | 0e7f9f3d4666f7bd864f65e87820f5a6b1a8f433 (diff) | |
download | rspamd-eec94c8f0a11902803983efe093e4b4de9359898.tar.gz rspamd-eec94c8f0a11902803983efe093e4b4de9359898.zip |
Add cleanup code for statistics
Diffstat (limited to 'src/libstat/stat_config.c')
-rw-r--r-- | src/libstat/stat_config.c | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/src/libstat/stat_config.c b/src/libstat/stat_config.c index bca4cd954..e307c276c 100644 --- a/src/libstat/stat_config.c +++ b/src/libstat/stat_config.c @@ -193,13 +193,37 @@ rspamd_stat_init (struct rspamd_config *cfg, struct event_base *ev_base) void rspamd_stat_close (void) { - guint i; + struct rspamd_classifier *cl; + struct rspamd_statfile *st; + struct rspamd_stat_ctx *st_ctx; + guint i, j; + gint id; - g_assert (stat_ctx != NULL); + st_ctx = rspamd_stat_get_ctx (); + g_assert (st_ctx != NULL); - /* TODO: add cleanup routine */ + for (i = 0; i < st_ctx->classifiers->len; i ++) { + cl = g_ptr_array_index (st_ctx->classifiers, i); + for (j = 0; j < cl->statfiles_ids->len; j ++) { + id = g_array_index (cl->statfiles_ids, gint, j); + st = g_ptr_array_index (st_ctx->statfiles, id); + st->backend->close (st->bkcf); + + g_slice_free1 (sizeof (*st), st); + } + + g_array_free (cl->statfiles_ids, TRUE); + g_slice_free1 (sizeof (*cl), cl); + } + + g_ptr_array_free (st_ctx->statfiles, TRUE); + g_ptr_array_free (st_ctx->classifiers, TRUE); REF_RELEASE (stat_ctx->cfg); + g_slice_free1 (sizeof (*st_ctx), st_ctx); + + /* Set global var to NULL */ + stat_ctx = NULL; } struct rspamd_stat_ctx * |