summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Lewis <nerf@judo.za.org>2017-07-07 12:14:28 +0200
committerAndrew Lewis <nerf@judo.za.org>2017-07-07 12:14:28 +0200
commit5bfd0fcf4988799f7e4f029df627687f22e55d83 (patch)
tree5a47095e68fc9018d0163e345178f330bf4021c2
parent5c631c922ae329bdca994d0a2967eee80d830cd3 (diff)
downloadrspamd-5bfd0fcf4988799f7e4f029df627687f22e55d83.tar.gz
rspamd-5bfd0fcf4988799f7e4f029df627687f22e55d83.zip
[Feature] Reload file maps more frequently
-rw-r--r--conf/options.inc2
-rw-r--r--src/libserver/cfg_file.h1
-rw-r--r--src/libserver/cfg_rcl.c6
-rw-r--r--src/libserver/cfg_utils.c2
-rw-r--r--src/libutil/map.c16
5 files changed, 26 insertions, 1 deletions
diff --git a/conf/options.inc b/conf/options.inc
index 5cb913cc7..fa974e681 100644
--- a/conf/options.inc
+++ b/conf/options.inc
@@ -6,6 +6,8 @@ one_shot = false;
cache_file = "$DBDIR/symbols.cache";
# How often maps are checked (
map_watch_interval = 5min;
+# Multiplier for watch interval for files
+map_file_watch_multiplier = 0.1;
dynamic_conf = "$DBDIR/rspamd_dynamic";
history_file = "$DBDIR/rspamd.history";
check_all_filters = false;
diff --git a/src/libserver/cfg_file.h b/src/libserver/cfg_file.h
index 2932bdd89..44b8dd85a 100644
--- a/src/libserver/cfg_file.h
+++ b/src/libserver/cfg_file.h
@@ -377,6 +377,7 @@ struct rspamd_config {
GList *maps; /**< maps active */
gdouble map_timeout; /**< maps watch timeout */
+ gdouble map_file_watch_multiplier; /**< multiplier for watch timeout when maps are files */
struct symbols_cache *cache; /**< symbols cache object */
gchar *cache_filename; /**< filename of cache file */
diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c
index ddc9ca066..67f91ab9b 100644
--- a/src/libserver/cfg_rcl.c
+++ b/src/libserver/cfg_rcl.c
@@ -1984,6 +1984,12 @@ rspamd_rcl_config_init (struct rspamd_config *cfg)
RSPAMD_CL_FLAG_TIME_FLOAT,
"Interval for checking maps");
rspamd_rcl_add_default_handler (sub,
+ "map_file_watch_multiplier",
+ rspamd_rcl_parse_struct_double,
+ G_STRUCT_OFFSET (struct rspamd_config, map_file_watch_multiplier),
+ 0,
+ "Multiplier for map watch interval when map is file");
+ rspamd_rcl_add_default_handler (sub,
"dynamic_conf",
rspamd_rcl_parse_struct_string,
G_STRUCT_OFFSET (struct rspamd_config, dynamic_conf),
diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c
index dce0e0bac..7bc8994b4 100644
--- a/src/libserver/cfg_utils.c
+++ b/src/libserver/cfg_utils.c
@@ -36,6 +36,7 @@
#define DEFAULT_RLIMIT_NOFILE 2048
#define DEFAULT_RLIMIT_MAXCORE 0
#define DEFAULT_MAP_TIMEOUT 60.0 * 5
+#define DEFAULT_MAP_FILE_WATCH_MULTIPLIER 1
#define DEFAULT_MIN_WORD 4
#define DEFAULT_MAX_WORD 40
#define DEFAULT_WORDS_DECAY 200
@@ -137,6 +138,7 @@ rspamd_config_new (void)
rspamd_str_equal);
cfg->map_timeout = DEFAULT_MAP_TIMEOUT;
+ cfg->map_file_watch_multiplier = DEFAULT_MAP_FILE_WATCH_MULTIPLIER;
cfg->log_level = G_LOG_LEVEL_WARNING;
cfg->log_extended = TRUE;
diff --git a/src/libutil/map.c b/src/libutil/map.c
index c0953c90f..4402a7910 100644
--- a/src/libutil/map.c
+++ b/src/libutil/map.c
@@ -1756,7 +1756,12 @@ rspamd_map_add (struct rspamd_config *cfg,
map->backends);
g_ptr_array_add (map->backends, bk);
map->name = rspamd_mempool_strdup (cfg->cfg_pool, map_line);
- map->poll_timeout = cfg->map_timeout;
+
+ if (bk->protocol == MAP_PROTO_FILE) {
+ map->poll_timeout = (cfg->map_timeout * cfg->map_file_watch_multiplier);
+ } else {
+ map->poll_timeout = cfg->map_timeout;
+ }
if (description != NULL) {
map->description = rspamd_mempool_strdup (cfg->cfg_pool, description);
@@ -1820,6 +1825,9 @@ rspamd_map_add_from_ucl (struct rspamd_config *cfg,
bk = rspamd_map_parse_backend (cfg, ucl_object_tostring (cur));
if (bk != NULL) {
+ if (bk->protocol == MAP_PROTO_FILE) {
+ map->poll_timeout = (map->poll_timeout * cfg->map_file_watch_multiplier);
+ }
g_ptr_array_add (map->backends, bk);
if (!map->name) {
@@ -1873,6 +1881,9 @@ rspamd_map_add_from_ucl (struct rspamd_config *cfg,
bk = rspamd_map_parse_backend (cfg, ucl_object_tostring (cur));
if (bk != NULL) {
+ if (bk->protocol == MAP_PROTO_FILE) {
+ map->poll_timeout = (map->poll_timeout * cfg->map_file_watch_multiplier);
+ }
g_ptr_array_add (map->backends, bk);
if (!map->name) {
@@ -1900,6 +1911,9 @@ rspamd_map_add_from_ucl (struct rspamd_config *cfg,
bk = rspamd_map_parse_backend (cfg, ucl_object_tostring (elt));
if (bk != NULL) {
+ if (bk->protocol == MAP_PROTO_FILE) {
+ map->poll_timeout = (map->poll_timeout * cfg->map_file_watch_multiplier);
+ }
g_ptr_array_add (map->backends, bk);
if (!map->name) {