]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Allow to configure images DCT cache size
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 10 Dec 2016 12:27:47 +0000 (12:27 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 10 Dec 2016 12:28:08 +0000 (12:28 +0000)
src/libmime/images.c
src/libserver/cfg_file.h
src/libserver/cfg_rcl.c
src/libserver/cfg_utils.c

index d6cd602a91910c0825c2ebf01b2592b265926a8c..72f585a143d50ff2b3e7fd332013c567c0f8d5d3 100644 (file)
@@ -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);
 }
index 2ce4bcb281a05d91d5038f15c732f6f6e1df8356..88b8cea4c3ca6c274836fd4eaaf82ffc299e6260 100644 (file)
@@ -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                                             */
index 42e406231abf352c1049f1e86ca7c6027747101f..b8423bb5dd1b09332e9f1b60b25dd98fa38cee27 100644 (file)
@@ -2022,6 +2022,12 @@ rspamd_rcl_config_init (struct rspamd_config *cfg)
                        G_STRUCT_OFFSET (struct rspamd_config, max_pic_size),
                        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,
index 2ead99f32f6a1b88f3c6bd905035c083306714c4..8fe971454c9a917899f7b5bea67b21db43e2b2f8 100644 (file)
@@ -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 ();