summaryrefslogtreecommitdiffstats
path: root/src/fuzzy_storage.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-01-05 12:04:31 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-01-05 12:04:31 +0000
commit9a28092a164e8ddb93153e18972cab5a6c049ff8 (patch)
treea23e3bcf1308da41cc8838cd01e5901a52e7a90d /src/fuzzy_storage.c
parent8fb2e907d41b71464a147e5e962f0f39d6a24b24 (diff)
downloadrspamd-9a28092a164e8ddb93153e18972cab5a6c049ff8.tar.gz
rspamd-9a28092a164e8ddb93153e18972cab5a6c049ff8.zip
[Fix] Fix fuzzy hashes count
Diffstat (limited to 'src/fuzzy_storage.c')
-rw-r--r--src/fuzzy_storage.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/fuzzy_storage.c b/src/fuzzy_storage.c
index 1e2826c23..f7549ac2f 100644
--- a/src/fuzzy_storage.c
+++ b/src/fuzzy_storage.c
@@ -124,6 +124,8 @@ struct rspamd_fuzzy_storage_ctx {
struct event_base *ev_base;
gint peer_fd;
struct event peer_ev;
+ struct event stat_ev;
+ struct timeval stat_tv;
/* Local keypair */
struct rspamd_cryptobox_keypair *default_keypair; /* Bad clash, need for parse keypair */
struct fuzzy_key *default_key;
@@ -448,6 +450,25 @@ fuzzy_update_version_callback (guint64 ver, void *ud)
}
static void
+fuzzy_stat_count_callback (guint64 count, void *ud)
+{
+ struct rspamd_fuzzy_storage_ctx *ctx = ud;
+
+ event_add (&ctx->stat_ev, &ctx->stat_tv);
+ ctx->stat.fuzzy_hashes = count;
+}
+
+static void
+rspamd_fuzzy_stat_callback (gint fd, gshort what, gpointer ud)
+{
+ struct rspamd_fuzzy_storage_ctx *ctx = ud;
+
+ event_del (&ctx->stat_ev);
+ rspamd_fuzzy_backend_count (ctx->backend, local_db_name,
+ fuzzy_stat_count_callback, ctx);
+}
+
+static void
rspamd_fuzzy_updates_cb (gboolean success, void *ud)
{
struct rspamd_updates_cbdata *cbdata = ud;
@@ -2292,6 +2313,11 @@ start_fuzzy (struct rspamd_worker *worker)
rspamd_fuzzy_storage_periodic_callback, ctx);
}
+ double_to_tv (ctx->sync_timeout, &ctx->stat_tv);
+ event_set (&ctx->stat_ev, -1, EV_TIMEOUT, rspamd_fuzzy_stat_callback, ctx);
+ event_base_set (ctx->ev_base, &ctx->stat_ev);
+ event_add (&ctx->stat_ev, &ctx->stat_tv);
+
if (ctx->mirrors && ctx->mirrors->len != 0) {
if (ctx->sync_keypair == NULL) {
GString *pk_str = NULL;