From 228b958489922e08eedfeaf545b4410aafed45da Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sat, 9 Dec 2017 15:54:01 +0000 Subject: [Minor] Avoid double scheduling for maps --- src/libutil/map.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/libutil/map.c') diff --git a/src/libutil/map.c b/src/libutil/map.c index e2874f7e2..0965201a8 100644 --- a/src/libutil/map.c +++ b/src/libutil/map.c @@ -1053,6 +1053,11 @@ rspamd_map_schedule_periodic (struct rspamd_map *map, gdouble timeout; struct map_periodic_cbdata *cbd; + if (map->scheduled_check) { + /* Do not schedule check if some check is already scheduled */ + return; + } + if (map->next_check != 0) { timeout = map->next_check - rspamd_get_calendar_ticks (); @@ -1098,6 +1103,7 @@ rspamd_map_schedule_periodic (struct rspamd_map *map, cbd->cbdata.cur_data = NULL; cbd->cbdata.map = map; cbd->map = map; + map->scheduled_check = TRUE; REF_INIT_RETAIN (cbd, rspamd_map_periodic_dtor); evtimer_set (&cbd->ev, rspamd_map_periodic_callback, cbd); @@ -1531,6 +1537,7 @@ rspamd_map_periodic_callback (gint fd, short what, void *ud) struct rspamd_map *map; map = cbd->map; + map->scheduled_check = FALSE; if (!cbd->locked) { if (!g_atomic_int_compare_and_exchange (cbd->map->locked, 0, 1)) { -- cgit v1.2.3