aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-12-10 12:27:47 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-12-10 12:28:08 +0000
commite80ac859a73deaf75da180e2446d62134b7f36ab (patch)
treecb1e8e1ff3cd54cbf23b123188c982d8e2cc5a29 /src
parenta32d867f9f22bd5da802e1d808d67a1b99aac075 (diff)
downloadrspamd-e80ac859a73deaf75da180e2446d62134b7f36ab.tar.gz
rspamd-e80ac859a73deaf75da180e2446d62134b7f36ab.zip
[Minor] Allow to configure images DCT cache size
Diffstat (limited to 'src')
-rw-r--r--src/libmime/images.c3
-rw-r--r--src/libserver/cfg_file.h1
-rw-r--r--src/libserver/cfg_rcl.c6
-rw-r--r--src/libserver/cfg_utils.c1
4 files changed, 9 insertions, 2 deletions
diff --git a/src/libmime/images.c b/src/libmime/images.c
index d6cd602a9..72f585a14 100644
--- a/src/libmime/images.c
+++ b/src/libmime/images.c
@@ -25,7 +25,6 @@
#include <math.h>
#define RSPAMD_NORMALIZED_DIM 64
-#define RSPAMD_IMAGES_CACHE_SIZE 256
static rspamd_lru_hash_t *images_hash = NULL;
#endif
@@ -372,7 +371,7 @@ rspamd_image_dct_equal (gconstpointer a, gconstpointer b)
static void
rspamd_image_create_cache (struct rspamd_config *cfg)
{
- images_hash = rspamd_lru_hash_new_full (RSPAMD_IMAGES_CACHE_SIZE, NULL,
+ images_hash = rspamd_lru_hash_new_full (cfg->images_cache_size, NULL,
rspamd_image_cache_entry_dtor,
rspamd_image_dct_hash, rspamd_image_dct_equal);
}
diff --git a/src/libserver/cfg_file.h b/src/libserver/cfg_file.h
index 2ce4bcb28..88b8cea4c 100644
--- a/src/libserver/cfg_file.h
+++ b/src/libserver/cfg_file.h
@@ -311,6 +311,7 @@ struct rspamd_config {
gchar *cores_dir; /**< directory for core files */
gsize max_message; /**< maximum size for messages */
gsize max_pic_size; /**< maximum size for a picture to process */
+ gsize images_cache_size; /**< size of LRU cache for DCT data from images */
enum rspamd_log_type log_type; /**< log type */
gint log_facility; /**< log facility in case of syslog */
diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c
index 42e406231..b8423bb5d 100644
--- a/src/libserver/cfg_rcl.c
+++ b/src/libserver/cfg_rcl.c
@@ -2023,6 +2023,12 @@ rspamd_rcl_config_init (struct rspamd_config *cfg)
RSPAMD_CL_FLAG_INT_SIZE,
"Maximum size of the picture to be normalized (1Mb by default)");
rspamd_rcl_add_default_handler (sub,
+ "images_cache",
+ rspamd_rcl_parse_struct_integer,
+ G_STRUCT_OFFSET (struct rspamd_config, max_pic_size),
+ RSPAMD_CL_FLAG_INT_SIZE,
+ "Size of DCT data cache for images (256 elements by default)");
+ rspamd_rcl_add_default_handler (sub,
"zstd_input_dictionary",
rspamd_rcl_parse_struct_string,
G_STRUCT_OFFSET (struct rspamd_config, zstd_input_dictionary),
diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c
index 2ead99f32..8fe971454 100644
--- a/src/libserver/cfg_utils.c
+++ b/src/libserver/cfg_utils.c
@@ -173,6 +173,7 @@ rspamd_config_new (void)
cfg->ssl_ciphers = "HIGH:!aNULL:!kRSA:!PSK:!SRP:!MD5:!RC4";
cfg->max_message = DEFAULT_MAX_MESSAGE;
cfg->max_pic_size = DEFAULT_MAX_PIC;
+ cfg->images_cache_size = 256;
cfg->monitored_ctx = rspamd_monitored_ctx_init ();
#ifdef WITH_HIREDIS
cfg->redis_pool = rspamd_redis_pool_init ();