From: Vsevolod Stakhov Date: Tue, 4 Jul 2017 07:49:57 +0000 (+0100) Subject: [Minor] Tweaks for sessions cache X-Git-Tag: 1.6.2~28 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a0a5b90f06b915ac5a123ecf219a688e2ce0df49;p=rspamd.git [Minor] Tweaks for sessions cache --- diff --git a/src/libserver/cfg_file.h b/src/libserver/cfg_file.h index 8c7b39262..2932bdd89 100644 --- a/src/libserver/cfg_file.h +++ b/src/libserver/cfg_file.h @@ -412,7 +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 */ + guint max_sessions_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 f4ca6ded7..ddc9ca066 100644 --- a/src/libserver/cfg_rcl.c +++ b/src/libserver/cfg_rcl.c @@ -2206,9 +2206,9 @@ rspamd_rcl_config_init (struct rspamd_config *cfg) 0, "Enable sessions cache to debug dangling sessions"); rspamd_rcl_add_default_handler (sub, - "max_session_cache", + "max_sessions_cache", rspamd_rcl_parse_struct_integer, - G_STRUCT_OFFSET (struct rspamd_config, max_session_cache), + G_STRUCT_OFFSET (struct rspamd_config, max_sessions_cache), 0, "Maximum number of sessions in cache before warning (default: 100)"); diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c index abc647dcb..dce0e0bac 100644 --- a/src/libserver/cfg_utils.c +++ b/src/libserver/cfg_utils.c @@ -182,7 +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; + cfg->max_sessions_cache = DEFAULT_MAX_SESSIONS; REF_INIT_RETAIN (cfg, rspamd_config_free); diff --git a/src/libserver/worker_util.c b/src/libserver/worker_util.c index bb6f9221d..fcd9a8be9 100644 --- a/src/libserver/worker_util.c +++ b/src/libserver/worker_util.c @@ -717,7 +717,7 @@ rspamd_session_cache_sort_cmp (gconstpointer pa, gconstpointer pb) *e1 = *(const struct rspamd_worker_session_elt **)pa, *e2 = *(const struct rspamd_worker_session_elt **)pb; - return e1->when < e2->when; + return e2->when < e1->when; } static void @@ -732,7 +732,7 @@ rspamd_sessions_cache_periodic (gint fd, short what, gpointer p) GPtrArray *res; guint i; - if (g_hash_table_size (c->cache) > c->cfg->max_session_cache) { + if (g_hash_table_size (c->cache) > c->cfg->max_sessions_cache) { res = g_ptr_array_sized_new (g_hash_table_size (c->cache)); g_hash_table_iter_init (&it, c->cache); @@ -741,7 +741,7 @@ rspamd_sessions_cache_periodic (gint fd, short what, gpointer p) } msg_err ("sessions cache is overflowed %d elements where %d is limit", - (gint)res->len, (gint)c->cfg->max_session_cache); + (gint)res->len, (gint)c->cfg->max_sessions_cache); g_ptr_array_sort (res, rspamd_session_cache_sort_cmp); PTR_ARRAY_FOREACH (res, i, elt) {