aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstat/stat_config.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-06-18 19:07:25 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-06-22 10:57:29 +0100
commita3a8b32851bd236333af1353dad0d663f30a555d (patch)
treead9255b7e1b7a9057071b9aa65883c35a89d5703 /src/libstat/stat_config.c
parentd5a36f4f750e63294cefed10f55b29fe7409bba6 (diff)
downloadrspamd-a3a8b32851bd236333af1353dad0d663f30a555d.tar.gz
rspamd-a3a8b32851bd236333af1353dad0d663f30a555d.zip
[Project] More rework
Diffstat (limited to 'src/libstat/stat_config.c')
-rw-r--r--src/libstat/stat_config.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/src/libstat/stat_config.c b/src/libstat/stat_config.c
index 1ad064c53..52c78ba6b 100644
--- a/src/libstat/stat_config.c
+++ b/src/libstat/stat_config.c
@@ -163,7 +163,7 @@ rspamd_stat_init (struct rspamd_config *cfg, struct ev_loop *ev_base)
stat_ctx->statfiles = g_ptr_array_new ();
stat_ctx->classifiers = g_ptr_array_new ();
stat_ctx->async_elts = g_queue_new ();
- stat_ctx->ev_base = ev_base;
+ stat_ctx->event_loop = ev_base;
stat_ctx->lua_stat_tokens_ref = -1;
/* Interact with lua_stat */
@@ -510,25 +510,24 @@ rspamd_async_elt_dtor (struct rspamd_stat_async_elt *elt)
elt->cleanup (elt, elt->ud);
}
- event_del (&elt->timer_ev);
+ ev_timer_stop (elt->event_loop, &elt->timer_ev);
g_free (elt);
}
static void
-rspamd_async_elt_on_timer (gint fd, short what, gpointer d)
+rspamd_async_elt_on_timer (EV_P_ ev_timer *w, int revents)
{
- struct rspamd_stat_async_elt *elt = d;
+ struct rspamd_stat_async_elt *elt = (struct rspamd_stat_async_elt *)w->data;
gdouble jittered_time;
- event_del (&elt->timer_ev);
if (elt->enabled) {
elt->handler (elt, elt->ud);
}
jittered_time = rspamd_time_jitter (elt->timeout, 0);
- double_to_tv (jittered_time, &elt->tv);
- event_add (&elt->timer_ev, &elt->tv);
+ elt->timer_ev.repeat = jittered_time;
+ ev_timer_again (EV_A_ w);
}
struct rspamd_stat_async_elt*
@@ -548,21 +547,19 @@ rspamd_stat_ctx_register_async (rspamd_stat_async_handler handler,
elt->cleanup = cleanup;
elt->ud = d;
elt->timeout = timeout;
+ elt->event_loop = st_ctx->event_loop;
REF_INIT_RETAIN (elt, rspamd_async_elt_dtor);
/* Enabled by default */
- if (st_ctx->ev_base) {
+ if (st_ctx->event_loop) {
elt->enabled = TRUE;
- event_set (&elt->timer_ev, -1, EV_TIMEOUT, rspamd_async_elt_on_timer, elt);
- event_base_set (st_ctx->ev_base, &elt->timer_ev);
/*
* First we set timeval to zero as we want cb to be executed as
* fast as possible
*/
- elt->tv.tv_sec = 0;
- elt->tv.tv_usec = 0;
- event_add (&elt->timer_ev, &elt->tv);
+ ev_timer_init (&elt->timer_ev, rspamd_async_elt_on_timer, 0.0, 0.0);
+ ev_timer_start (st_ctx->event_loop, &elt->timer_ev);
}
else {
elt->enabled = FALSE;