From: Vsevolod Stakhov Date: Tue, 4 Jul 2017 07:33:00 +0000 (+0100) Subject: [Minor] Add configuration knobs for sessions cache X-Git-Tag: 1.6.2~31 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=dde53bb20d667ef89093fb9fb5819c4b1a2a519e;p=rspamd.git [Minor] Add configuration knobs for sessions cache --- diff --git a/src/libserver/cfg_file.h b/src/libserver/cfg_file.h index e48eb6db0..8c7b39262 100644 --- a/src/libserver/cfg_file.h +++ b/src/libserver/cfg_file.h @@ -308,6 +308,7 @@ struct rspamd_config { gboolean ignore_received; /**< Ignore data from the first received header */ gboolean check_local; /** Don't disable any checks for local networks */ gboolean check_authed; /** Don't disable any checks for authenticated users */ + gboolean enable_sessions_cache; /**< Enable session cache for debug */ gsize max_diff; /**< maximum diff size for text parts */ gsize max_cores_size; /**< maximum size occupied by rspamd core files */ @@ -411,6 +412,7 @@ struct rspamd_config { guint max_word_len; /**< maximum length of the word to be considered */ guint words_decay; /**< limit for words for starting adaptive ignoring */ guint history_rows; /**< number of history rows stored */ + guint max_session_cache; /**< maximum number of sessions cache elts */ GList *classify_headers; /**< list of headers using for statistics */ struct module_s **compiled_modules; /**< list of compiled C modules */ diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c index bf3a1779f..f4ca6ded7 100644 --- a/src/libserver/cfg_rcl.c +++ b/src/libserver/cfg_rcl.c @@ -2199,6 +2199,18 @@ rspamd_rcl_config_init (struct rspamd_config *cfg) G_STRUCT_OFFSET (struct rspamd_config, default_max_shots), 0, "Maximum number of hits per a single symbol (default: 100)"); + rspamd_rcl_add_default_handler (sub, + "sessions_cache", + rspamd_rcl_parse_struct_boolean, + G_STRUCT_OFFSET (struct rspamd_config, enable_sessions_cache), + 0, + "Enable sessions cache to debug dangling sessions"); + rspamd_rcl_add_default_handler (sub, + "max_session_cache", + rspamd_rcl_parse_struct_integer, + G_STRUCT_OFFSET (struct rspamd_config, max_session_cache), + 0, + "Maximum number of sessions in cache before warning (default: 100)"); /* Neighbours configuration */ rspamd_rcl_add_section_doc (&sub->subsections, "neighbours", "name", diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c index 4966c37d6..abc647dcb 100644 --- a/src/libserver/cfg_utils.c +++ b/src/libserver/cfg_utils.c @@ -42,6 +42,7 @@ #define DEFAULT_MAX_MESSAGE (50 * 1024 * 1024) #define DEFAULT_MAX_PIC (1 * 1024 * 1024) #define DEFAULT_MAX_SHOTS 100 +#define DEFAULT_MAX_SESSIONS 100 struct rspamd_ucl_map_cbdata { struct rspamd_config *cfg; @@ -181,6 +182,7 @@ rspamd_config_new (void) cfg->redis_pool = rspamd_redis_pool_init (); #endif cfg->default_max_shots = DEFAULT_MAX_SHOTS; + cfg->max_session_cache = DEFAULT_MAX_SESSIONS; REF_INIT_RETAIN (cfg, rspamd_config_free);