]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Fix scheduling of locked map events
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 1 Jul 2016 10:53:42 +0000 (11:53 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 1 Jul 2016 10:56:07 +0000 (11:56 +0100)
src/libutil/map.c

index a29939f26bb9bf85cb9a711b0de0c052f25155ff..354ac722ec736c6c75c1a6f96c886628795ca1a2 100644 (file)
@@ -599,9 +599,8 @@ rspamd_map_periodic_dtor (struct map_periodic_cbdata *periodic)
                /* Not modified */
        }
 
-       rspamd_map_schedule_periodic (periodic->map, FALSE, FALSE, FALSE);
-
        if (periodic->locked) {
+               rspamd_map_schedule_periodic (periodic->map, FALSE, FALSE, FALSE);
                g_atomic_int_set (periodic->map->locked, 0);
        }
 
@@ -627,7 +626,7 @@ rspamd_map_schedule_periodic (struct rspamd_map *map,
                timeout = map->poll_timeout * error_mult;
        }
        else if (locked) {
-               timeout = map->poll_timeout * lock_mult;
+               timeout = lock_mult;
        }
 
        cbd = g_slice_alloc0 (sizeof (*cbd));
@@ -638,8 +637,6 @@ rspamd_map_schedule_periodic (struct rspamd_map *map,
        cbd->map = map;
        REF_INIT_RETAIN (cbd, rspamd_map_periodic_dtor);
 
-       msg_debug_map ("schedule new periodic event %p in %.2f seconds", cbd, timeout);
-
        if (initial) {
                evtimer_set (&map->ev, rspamd_map_periodic_callback, cbd);
                event_base_set (map->ev_base, &map->ev);
@@ -647,9 +644,11 @@ rspamd_map_schedule_periodic (struct rspamd_map *map,
        else {
                evtimer_del (&map->ev);
                evtimer_set (&map->ev, rspamd_map_periodic_callback, cbd);
+               event_base_set (map->ev_base, &map->ev);
        }
 
        jittered_sec = rspamd_time_jitter (timeout, 0);
+       msg_debug_map ("schedule new periodic event %p in %.2f seconds", cbd, jittered_sec);
        double_to_tv (jittered_sec, &map->tv);
 
        evtimer_add (&map->ev, &map->tv);