]> source.dussan.org Git - rspamd.git/commitdiff
Use common routine for jittering time values.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 14 Jun 2015 18:17:29 +0000 (14:17 -0400)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 14 Jun 2015 18:17:29 +0000 (14:17 -0400)
src/fuzzy_storage.c
src/libutil/map.c

index 052cf64c9a4ad0b1d56c9cdef3e1b414f41bfabb..f544c40907edc5148109928f4d1483893e949619 100644 (file)
@@ -311,8 +311,7 @@ sync_callback (gint fd, short what, void *arg)
        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);
 
index 3fe7495b31f982f6f6af0dc343c8ec0c3110db30..afb31c9531d409acc04e1f2a49acdabebe57408c 100644 (file)
@@ -285,14 +285,7 @@ jitter_timeout_event (struct rspamd_map *map, gboolean locked, gboolean initial)
 
        /* 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);