From: Vsevolod Stakhov Date: Wed, 9 Dec 2015 15:46:20 +0000 (+0000) Subject: Add silent mode for hyperscan validity checks X-Git-Tag: 1.1.0~356 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=51c2dbec80f7b8e637139d82ee68edaaa739181a;p=thirdparty%2Frspamd.git Add silent mode for hyperscan validity checks --- diff --git a/src/hs_helper.c b/src/hs_helper.c index ab90b83344..4d89bedf80 100644 --- a/src/hs_helper.c +++ b/src/hs_helper.c @@ -106,7 +106,7 @@ rspamd_hs_helper_cleanup_dir (struct hs_helper_ctx *ctx) if ((rc = glob (pattern, GLOB_DOOFFS, NULL, &globbuf)) == 0) { for (i = 0; i < globbuf.gl_pathc; i++) { if (!rspamd_re_cache_is_valid_hyperscan_file (ctx->cfg->re_cache, - globbuf.gl_pathv[i])) { + globbuf.gl_pathv[i], TRUE)) { if (unlink (globbuf.gl_pathv[i]) == -1) { msg_err ("cannot unlink %s: %s", globbuf.gl_pathv[i], strerror (errno)); diff --git a/src/libserver/re_cache.c b/src/libserver/re_cache.c index e1a636c742..4f4a1881c5 100644 --- a/src/libserver/re_cache.c +++ b/src/libserver/re_cache.c @@ -971,7 +971,7 @@ rspamd_re_cache_compile_hyperscan (struct rspamd_re_cache *cache, rspamd_snprintf (path, sizeof (path), "%s%c%s.hs", cache_dir, G_DIR_SEPARATOR, re_class->hash); - if (rspamd_re_cache_is_valid_hyperscan_file (cache, path)) { + if (rspamd_re_cache_is_valid_hyperscan_file (cache, path, TRUE)) { msg_info_re_cache ("skip already valid file for re class '%s'", re_class->hash); @@ -983,6 +983,7 @@ rspamd_re_cache_compile_hyperscan (struct rspamd_re_cache *cache, read (fd, &n, sizeof (n)); total += n; close (fd); + continue; } @@ -1143,7 +1144,7 @@ rspamd_re_cache_compile_hyperscan (struct rspamd_re_cache *cache, gboolean rspamd_re_cache_is_valid_hyperscan_file (struct rspamd_re_cache *cache, - const char *path) + const char *path, gboolean silent) { g_assert (cache != NULL); g_assert (path != NULL); @@ -1181,8 +1182,10 @@ rspamd_re_cache_is_valid_hyperscan_file (struct rspamd_re_cache *cache, fd = open (path, O_RDONLY); if (fd == -1) { - msg_err_re_cache ("cannot open hyperscan cache file %s: %s", - path, strerror (errno)); + if (!silent) { + msg_err_re_cache ("cannot open hyperscan cache file %s: %s", + path, strerror (errno)); + } return FALSE; } @@ -1226,7 +1229,9 @@ rspamd_re_cache_is_valid_hyperscan_file (struct rspamd_re_cache *cache, } } - msg_warn_re_cache ("unknown hyperscan cache file %s", path); + if (!silent) { + msg_warn_re_cache ("unknown hyperscan cache file %s", path); + } return FALSE; #endif @@ -1259,7 +1264,7 @@ rspamd_re_cache_load_hyperscan (struct rspamd_re_cache *cache, rspamd_snprintf (path, sizeof (path), "%s%c%s.hs", cache_dir, G_DIR_SEPARATOR, re_class->hash); - if (rspamd_re_cache_is_valid_hyperscan_file (cache, path)) { + if (rspamd_re_cache_is_valid_hyperscan_file (cache, path, FALSE)) { msg_debug_re_cache ("load hyperscan database from '%s'", re_class->hash); diff --git a/src/libserver/re_cache.h b/src/libserver/re_cache.h index c812b8ef32..0fffc2d7cb 100644 --- a/src/libserver/re_cache.h +++ b/src/libserver/re_cache.h @@ -136,7 +136,7 @@ gint rspamd_re_cache_compile_hyperscan (struct rspamd_re_cache *cache, * Returns TRUE if the specified file is valid hyperscan cache */ gboolean rspamd_re_cache_is_valid_hyperscan_file (struct rspamd_re_cache *cache, - const char *path); + const char *path, gboolean silent); /** * Loads all hyperscan regexps precompiled