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);
/* Plan event again with jitter */
evtimer_del (&map->ev);
- jittered_sec = timeout;
- if (locked) {
- /* Add bigger jitter */
- jittered_sec += g_random_double () * timeout * 4;
- }
- else {
- jittered_sec += g_random_double () * timeout;
- }
+ jittered_sec = rspamd_time_jitter (locked ? timeout * 4 : timeout, 0);
double_to_tv (jittered_sec, &map->tv);
evtimer_add (&map->ev, &map->tv);