summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-07-18 13:37:44 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-07-18 13:37:44 +0100
commit5c8b2d3ad79003c8e6dba2789e2d7f3a358e5648 (patch)
tree0e67502db3c6d44a6b66e59551c751426df3a5fd /src
parentcdffc67c726572a222dae58144502ec68c8b1359 (diff)
downloadrspamd-5c8b2d3ad79003c8e6dba2789e2d7f3a358e5648.tar.gz
rspamd-5c8b2d3ad79003c8e6dba2789e2d7f3a358e5648.zip
[Fix] Do not reduce map watch timeout for mixed http/file maps
Diffstat (limited to 'src')
-rw-r--r--src/libutil/map.c100
1 files changed, 50 insertions, 50 deletions
diff --git a/src/libutil/map.c b/src/libutil/map.c
index d184d32ed..2e690ac55 100644
--- a/src/libutil/map.c
+++ b/src/libutil/map.c
@@ -2491,10 +2491,6 @@ 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) {
@@ -2548,9 +2544,6 @@ 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) {
@@ -2578,9 +2571,6 @@ 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) {
@@ -2594,59 +2584,69 @@ rspamd_map_add_from_ucl (struct rspamd_config *cfg,
msg_err_config ("map has no urls to be loaded: no valid backends");
goto err;
}
+ }
+ else {
+ msg_err_config ("map has invalid type for value: %s",
+ ucl_object_type_to_string (ucl_object_type (obj)));
+ goto err;
+ }
- PTR_ARRAY_FOREACH (map->backends, i, bk) {
- if (bk->protocol == MAP_PROTO_STATIC) {
- GString *map_data;
- /* We need data field in ucl */
- elt = ucl_object_lookup (obj, "data");
+ gboolean all_local = TRUE;
- if (elt == NULL) {
- msg_err_config ("map has static backend but no `data` field");
- goto err;
- }
+ PTR_ARRAY_FOREACH (map->backends, i, bk) {
+ if (bk->protocol == MAP_PROTO_STATIC) {
+ GString *map_data;
+ /* We need data field in ucl */
+ elt = ucl_object_lookup (obj, "data");
+ if (elt == NULL) {
+ msg_err_config ("map has static backend but no `data` field");
+ goto err;
+ }
- if (ucl_object_type (elt) == UCL_STRING) {
- map_data = g_string_sized_new (32);
- if (rspamd_map_add_static_string (cfg, elt, map_data)) {
- bk->data.sd->data = map_data->str;
- bk->data.sd->len = map_data->len;
- g_string_free (map_data, FALSE);
- }
- else {
- g_string_free (map_data, TRUE);
- msg_err_config ("map has static backend with invalid `data` field");
- goto err;
- }
- }
- else if (ucl_object_type (elt) == UCL_ARRAY) {
- map_data = g_string_sized_new (32);
- it = ucl_object_iterate_new (elt);
-
- while ((cur = ucl_object_iterate_safe (it, true))) {
- if (!rspamd_map_add_static_string (cfg, cur, map_data)) {
- g_string_free (map_data, TRUE);
- msg_err_config ("map has static backend with invalid "
- "`data` field");
- ucl_object_iterate_free (it);
- goto err;
- }
- }
+ if (ucl_object_type (elt) == UCL_STRING) {
+ map_data = g_string_sized_new (32);
- ucl_object_iterate_free (it);
+ if (rspamd_map_add_static_string (cfg, elt, map_data)) {
bk->data.sd->data = map_data->str;
bk->data.sd->len = map_data->len;
g_string_free (map_data, FALSE);
}
+ else {
+ g_string_free (map_data, TRUE);
+ msg_err_config ("map has static backend with invalid `data` field");
+ goto err;
+ }
+ }
+ else if (ucl_object_type (elt) == UCL_ARRAY) {
+ map_data = g_string_sized_new (32);
+ it = ucl_object_iterate_new (elt);
+
+ while ((cur = ucl_object_iterate_safe (it, true))) {
+ if (!rspamd_map_add_static_string (cfg, cur, map_data)) {
+ g_string_free (map_data, TRUE);
+ msg_err_config ("map has static backend with invalid "
+ "`data` field");
+ ucl_object_iterate_free (it);
+ goto err;
+ }
+ }
+
+ ucl_object_iterate_free (it);
+ bk->data.sd->data = map_data->str;
+ bk->data.sd->len = map_data->len;
+ g_string_free (map_data, FALSE);
}
}
+ else if (bk->protocol != MAP_PROTO_FILE) {
+ all_local = FALSE;
+ }
}
- else {
- msg_err_config ("map has invalid type for value: %s",
- ucl_object_type_to_string (ucl_object_type (obj)));
- goto err;
+
+ if (all_local) {
+ map->poll_timeout = (map->poll_timeout *
+ cfg->map_file_watch_multiplier);
}
rspamd_map_calculate_hash (map);