From: Vsevolod Stakhov Date: Sun, 13 Jul 2025 14:56:58 +0000 (+0100) Subject: [Minor] Improve logging X-Git-Tag: 3.13.0~47^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bfdf70f3edbb41f4495a37484c175dc14d860436;p=thirdparty%2Frspamd.git [Minor] Improve logging --- diff --git a/src/libserver/re_cache.c b/src/libserver/re_cache.c index 7c5e146162..06ba26528d 100644 --- a/src/libserver/re_cache.c +++ b/src/libserver/re_cache.c @@ -2215,21 +2215,27 @@ rspamd_re_cache_compile_timer_cb(EV_P_ ev_timer *w, int revents) if (re_class->type_len > 0) { if (!cbdata->silent) { msg_info_re_cache( - "skip already valid class %s(%*s) to cache %6s, %d regexps", + "skip already valid class %s(%*s) to cache %6s, %d regexps%s%s%s", rspamd_re_cache_type_to_string(re_class->type), (int) re_class->type_len - 1, re_class->type_data, re_class->hash, - n); + n, + cache->scope ? " for scope '" : "", + cache->scope ? cache->scope : "", + cache->scope ? "'" : ""); } } else { if (!cbdata->silent) { msg_info_re_cache( - "skip already valid class %s to cache %6s, %d regexps", + "skip already valid class %s to cache %6s, %d regexps%s%s%s", rspamd_re_cache_type_to_string(re_class->type), re_class->hash, - n); + n, + cache->scope ? " for scope '" : "", + cache->scope ? cache->scope : "", + cache->scope ? "'" : ""); } } @@ -2438,21 +2444,27 @@ rspamd_re_cache_compile_timer_cb(EV_P_ ev_timer *w, int revents) if (re_class->type_len > 0) { msg_info_re_cache( - "compiled class %s(%*s) to cache %6s, %d/%d regexps", + "compiled class %s(%*s) to cache %6s, %d/%d regexps%s%s%s", rspamd_re_cache_type_to_string(re_class->type), (int) re_class->type_len - 1, re_class->type_data, re_class->hash, n, - (int) g_hash_table_size(re_class->re)); + (int) g_hash_table_size(re_class->re), + cache->scope ? " for scope '" : "", + cache->scope ? cache->scope : "", + cache->scope ? "'" : ""); } else { msg_info_re_cache( - "compiled class %s to cache %6s, %d/%d regexps", + "compiled class %s to cache %6s, %d/%d regexps%s%s%s", rspamd_re_cache_type_to_string(re_class->type), re_class->hash, n, - (int) g_hash_table_size(re_class->re)); + (int) g_hash_table_size(re_class->re), + cache->scope ? " for scope '" : "", + cache->scope ? cache->scope : "", + cache->scope ? "'" : ""); } cbdata->total += n; @@ -3059,16 +3071,27 @@ rspamd_re_cache_load_hyperscan(struct rspamd_re_cache *cache, if (has_valid) { if (all_valid) { - msg_info_re_cache("full hyperscan database of %d regexps has been loaded", total); + msg_info_re_cache("full hyperscan database of %d regexps has been loaded%s%s%s", + total, + cache->scope ? " for scope '" : "", + cache->scope ? cache->scope : "", + cache->scope ? "'" : ""); cache->hyperscan_loaded = RSPAMD_HYPERSCAN_LOADED_FULL; } else { - msg_info_re_cache("partial hyperscan database of %d regexps has been loaded", total); + msg_info_re_cache("partial hyperscan database of %d regexps has been loaded%s%s%s", + total, + cache->scope ? " for scope '" : "", + cache->scope ? cache->scope : "", + cache->scope ? "'" : ""); cache->hyperscan_loaded = RSPAMD_HYPERSCAN_LOADED_PARTIAL; } } else { - msg_info_re_cache("hyperscan database has NOT been loaded; no valid expressions"); + msg_info_re_cache("hyperscan database has NOT been loaded; no valid expressions%s%s%s", + cache->scope ? " for scope '" : "", + cache->scope ? cache->scope : "", + cache->scope ? "'" : ""); cache->hyperscan_loaded = RSPAMD_HYPERSCAN_LOAD_ERROR; } diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c index 5416eae3cf..c9bd40691c 100644 --- a/src/lua/lua_config.c +++ b/src/lua/lua_config.c @@ -5397,6 +5397,13 @@ lua_config_set_regexp_scope_loaded(lua_State *L) if (loaded) { rspamd_re_cache_set_flags(cfg->re_cache, scope, RSPAMD_RE_CACHE_FLAG_LOADED); + + /* When marking a scope as loaded, we also need to initialize it + * to compute the hash for each re_class */ + struct rspamd_re_cache *target_cache = rspamd_re_cache_find_scope(cfg->re_cache, scope); + if (target_cache) { + rspamd_re_cache_init(target_cache, cfg); + } } else { rspamd_re_cache_clear_flags(cfg->re_cache, scope, RSPAMD_RE_CACHE_FLAG_LOADED);