diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-09-28 12:35:49 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-09-28 12:35:49 +0100 |
commit | f91453c70541a6c877637d7864c040ecfa413da9 (patch) | |
tree | fcba6c976130c9164456a51a5f77fd71d1e6ea53 /src/fuzzy_storage.c | |
parent | 9c44caea68a12837ab2c99fddd6ba5e7b907240f (diff) | |
download | rspamd-f91453c70541a6c877637d7864c040ecfa413da9.tar.gz rspamd-f91453c70541a6c877637d7864c040ecfa413da9.zip |
More sync optimizations.
Diffstat (limited to 'src/fuzzy_storage.c')
-rw-r--r-- | src/fuzzy_storage.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/fuzzy_storage.c b/src/fuzzy_storage.c index ebbff3365..5b5737a9f 100644 --- a/src/fuzzy_storage.c +++ b/src/fuzzy_storage.c @@ -267,18 +267,19 @@ sync_callback (gint fd, short what, void *arg) gdouble next_check; ctx = worker->ctx; + /* Call backend sync */ + rspamd_fuzzy_backend_sync (ctx->backend, ctx->expire, FALSE); + + server_stat->fuzzy_hashes_expired = rspamd_fuzzy_backend_expired (ctx->backend); + /* Timer event */ + event_del (&tev); evtimer_set (&tev, sync_callback, worker); event_base_set (ctx->ev_base, &tev); /* Plan event with jitter */ next_check = rspamd_time_jitter (ctx->sync_timeout, 0); double_to_tv (next_check, &tmv); evtimer_add (&tev, &tmv); - - /* Call backend sync */ - rspamd_fuzzy_backend_sync (ctx->backend, ctx->expire); - - server_stat->fuzzy_hashes_expired = rspamd_fuzzy_backend_expired (ctx->backend); } gpointer @@ -352,12 +353,12 @@ start_fuzzy (struct rspamd_worker *worker) server_stat->fuzzy_hashes = rspamd_fuzzy_backend_count (ctx->backend); + rspamd_fuzzy_backend_sync (ctx->backend, ctx->expire, TRUE); /* Timer event */ evtimer_set (&tev, sync_callback, worker); event_base_set (ctx->ev_base, &tev); /* Plan event with jitter */ - next_check = ctx->sync_timeout * (1. + ((gdouble)ottery_rand_uint32 ()) / - G_MAXUINT32); + next_check = rspamd_time_jitter (ctx->sync_timeout, 0); double_to_tv (next_check, &tmv); evtimer_add (&tev, &tmv); @@ -379,7 +380,7 @@ start_fuzzy (struct rspamd_worker *worker) event_base_loop (ctx->ev_base, 0); - rspamd_fuzzy_backend_sync (ctx->backend, ctx->expire); + rspamd_fuzzy_backend_sync (ctx->backend, ctx->expire, TRUE); rspamd_fuzzy_backend_close (ctx->backend); rspamd_log_close (rspamd_main->logger); exit (EXIT_SUCCESS); |