summaryrefslogtreecommitdiffstats
path: root/src/libutil/map.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-10-28 12:08:29 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-10-28 12:08:29 +0000
commit80264529d0c16f28223f827f46eaa2838046a84d (patch)
tree56b04e0da4434860135da2d4dd77c5bb31778110 /src/libutil/map.c
parent0d5f9d30bcb193fc9131b4d3a8c216d79f29636b (diff)
downloadrspamd-80264529d0c16f28223f827f46eaa2838046a84d.tar.gz
rspamd-80264529d0c16f28223f827f46eaa2838046a84d.zip
[Minor] Improve trivial maps handling
Diffstat (limited to 'src/libutil/map.c')
-rw-r--r--src/libutil/map.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/libutil/map.c b/src/libutil/map.c
index 808b2a69a..6bcf8d081 100644
--- a/src/libutil/map.c
+++ b/src/libutil/map.c
@@ -1006,6 +1006,11 @@ rspamd_map_schedule_periodic (struct rspamd_map *map, int how)
return;
}
+ if (!(how & RSPAMD_MAP_SCHEDULE_INIT) && map->static_only) {
+ /* No need to schedule anything for static maps */
+ return;
+ }
+
if (map->non_trivial && map->next_check != 0) {
timeout = map->next_check - rspamd_get_calendar_ticks ();
@@ -1850,7 +1855,7 @@ rspamd_map_process_periodic (struct map_periodic_cbdata *cbd)
map = cbd->map;
map->scheduled_check = NULL;
- if (!cbd->locked) {
+ if (!map->file_only && !cbd->locked) {
if (!g_atomic_int_compare_and_exchange (cbd->map->locked, 0, 1)) {
msg_debug_map (
"don't try to reread map %s as it is locked by other process, "
@@ -1996,6 +2001,9 @@ rspamd_map_watch (struct rspamd_config *cfg,
}
}
+ map->file_only = TRUE;
+ map->static_only = TRUE;
+
PTR_ARRAY_FOREACH (map->backends, i, bk) {
bk->event_loop = event_loop;
@@ -2008,10 +2016,16 @@ rspamd_map_watch (struct rspamd_config *cfg,
data->filename, map->poll_timeout * cfg->map_file_watch_multiplier);
data->st_ev.data = map;
ev_stat_start (event_loop, &data->st_ev);
+ map->static_only = FALSE;
}
else if ((bk->protocol == MAP_PROTO_HTTP ||
- bk->protocol == MAP_PROTO_HTTPS) && map->active_http) {
- map->non_trivial = TRUE;
+ bk->protocol == MAP_PROTO_HTTPS)) {
+ if (map->active_http) {
+ map->non_trivial = TRUE;
+ }
+
+ map->static_only = FALSE;
+ map->file_only = FALSE;
}
}