summaryrefslogtreecommitdiffstats
path: root/src/libutil
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
parent592fd69d4f6d339001d24bbe7b772c1da9395643 (diff)
downloadrspamd-228b958489922e08eedfeaf545b4410aafed45da.tar.gz
rspamd-228b958489922e08eedfeaf545b4410aafed45da.zip
[Minor] Avoid double scheduling for maps
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/map.c7
-rw-r--r--src/libutil/map_private.h3
2 files changed, 9 insertions, 1 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)) {
diff --git a/src/libutil/map_private.h b/src/libutil/map_private.h
index 55641f3dd..fd2098cd1 100644
--- a/src/libutil/map_private.h
+++ b/src/libutil/map_private.h
@@ -113,6 +113,7 @@ struct rspamd_map {
gchar *description;
gchar *name;
guint32 id;
+ gboolean scheduled_check;
/* Should we check HTTP or just load cached data */
gboolean active_http;
struct timeval tv;
@@ -142,8 +143,8 @@ struct map_periodic_cbdata {
struct event ev;
gboolean need_modify;
gboolean errored;
- guint cur_backend;
gboolean locked;
+ guint cur_backend;
ref_entry_t ref;
};