aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-05-13 11:10:42 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-05-13 11:10:42 +0100
commit562fff4f39bdab9a10fe24fab72cc4484ace1c59 (patch)
tree659330def154f7bfab99bb72e3b3a4c366fdbff2
parent9dc7bf904bf62b332cfd5a0a99a195cef19149d7 (diff)
downloadrspamd-562fff4f39bdab9a10fe24fab72cc4484ace1c59.tar.gz
rspamd-562fff4f39bdab9a10fe24fab72cc4484ace1c59.zip
[Fix] Fix events handling when scheduling map wacth
-rw-r--r--src/libutil/map.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/libutil/map.c b/src/libutil/map.c
index f52844edd..c4112bfd1 100644
--- a/src/libutil/map.c
+++ b/src/libutil/map.c
@@ -584,18 +584,18 @@ rspamd_map_schedule_periodic (struct rspamd_map *map,
gdouble timeout;
struct map_periodic_cbdata *cbd;
+ timeout = map->poll_timeout;
+
if (initial) {
timeout = 0.0;
}
- else if (errored) {
+
+ if (errored) {
timeout = map->poll_timeout * error_mult;
}
else if (locked) {
timeout = map->poll_timeout * lock_mult;
}
- else {
- timeout = map->poll_timeout;
- }
cbd = g_slice_alloc0 (sizeof (*cbd));
cbd->cbdata.state = 0;
@@ -604,11 +604,15 @@ rspamd_map_schedule_periodic (struct rspamd_map *map,
cbd->cbdata.map = map;
cbd->map = map;
REF_INIT_RETAIN (cbd, rspamd_map_periodic_dtor);
- evtimer_set (&map->ev, rspamd_map_periodic_callback, cbd);
- event_base_set (map->ev_base, &map->ev);
- /* Plan event again with jitter */
- evtimer_del (&map->ev);
+ if (initial) {
+ evtimer_set (&map->ev, rspamd_map_periodic_callback, cbd);
+ event_base_set (map->ev_base, &map->ev);
+ }
+ else {
+ evtimer_del (&map->ev);
+ }
+
jittered_sec = rspamd_time_jitter (timeout, 0);
double_to_tv (jittered_sec, &map->tv);
@@ -881,7 +885,7 @@ rspamd_map_watch (struct rspamd_config *cfg,
msg_debug_map (
"don't try to reread map as it is locked by other process, "
"will reread it later");
- rspamd_map_schedule_periodic (map, TRUE, FALSE, FALSE);
+ rspamd_map_schedule_periodic (map, TRUE, TRUE, FALSE);
}
else {
rspamd_map_schedule_periodic (map, FALSE, TRUE, FALSE);