aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil/map.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-12-09 15:54:01 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-12-09 15:54:01 +0000
commit228b958489922e08eedfeaf545b4410aafed45da (patch)
tree74581afd7d2b8aafc32f367ef1dbd51468ec2fff /src/libutil/map.c
parent592fd69d4f6d339001d24bbe7b772c1da9395643 (diff)
downloadrspamd-228b958489922e08eedfeaf545b4410aafed45da.tar.gz
rspamd-228b958489922e08eedfeaf545b4410aafed45da.zip
[Minor] Avoid double scheduling for maps
Diffstat (limited to 'src/libutil/map.c')
-rw-r--r--src/libutil/map.c7
1 files changed, 7 insertions, 0 deletions
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)) {