]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Some more fixes towards hyperscan obsoletion reasoning
authorVsevolod Stakhov <vsevolod@rspamd.com>
Fri, 8 Jul 2022 20:55:04 +0000 (21:55 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Fri, 8 Jul 2022 20:55:04 +0000 (21:55 +0100)
src/hs_helper.c
src/libserver/re_cache.c

index 3a74d5ddace9f984a72b54ae9807182ac2518f6c..4ec51aef45d481323d610c5785b9c1decb94a325 100644 (file)
@@ -144,20 +144,29 @@ rspamd_hs_helper_cleanup_dir (struct hs_helper_ctx *ctx, gboolean forced)
        if ((rc = glob (pattern, 0, NULL, &globbuf)) == 0) {
                for (i = 0; i < globbuf.gl_pathc; i++) {
                        GError *err = NULL;
+
+                       if (forced) {
+                               g_set_error(&err, g_quark_from_static_string ("re_cache"),
+                                               0, "forced removal");
+                       }
+
                        if (forced ||
                                        !rspamd_re_cache_is_valid_hyperscan_file (ctx->cfg->re_cache,
                                                globbuf.gl_pathv[i], TRUE, TRUE, &err)) {
                                if (unlink (globbuf.gl_pathv[i]) == -1) {
-                                       msg_err ("cannot unlink %s: %s", globbuf.gl_pathv[i],
-                                                       strerror (errno));
+                                       msg_err ("cannot unlink %s: %s (reason for expiration: %e)", globbuf.gl_pathv[i],
+                                                       strerror(errno));
                                        ret = FALSE;
                                }
                                else {
-                                       msg_notice ("successfully removed outdated hyperscan file: %s; %e",
+                                       msg_notice ("successfully removed outdated hyperscan file: %s; reason for expiration: %e",
                                                        globbuf.gl_pathv[i], err);
-                                       g_error_free(err);
                                }
                        }
+
+                       if (err) {
+                               g_error_free(err);
+                       }
                }
        }
        else if (rc != GLOB_NOMATCH) {
index a98ea50562567e0aeaec4b00ba76e7b50ba0452f..cb454d16dbf97b7c83752bfea7e03d86fbf8a21a 100644 (file)
@@ -2387,7 +2387,7 @@ rspamd_re_cache_is_valid_hyperscan_file (struct rspamd_re_cache *cache,
                                return FALSE;
                        }
 
-                       if (memcmp (&test_plt, &cache->plt, sizeof (test_plt)) != 0) {
+                       if (test_plt.cpu_features != cache->plt.cpu_features) {
                                msg_err_re_cache ("cannot open hyperscan cache file %s: "
                                                "compiled for a different platform",
                                                path);
@@ -2483,10 +2483,11 @@ rspamd_re_cache_is_valid_hyperscan_file (struct rspamd_re_cache *cache,
 
        if (!silent) {
                msg_warn_re_cache ("unknown hyperscan cache file %s", path);
-               g_set_error(err, rspamd_re_cache_quark(), 0,
-                               "unknown hyperscan file");
        }
 
+       g_set_error(err, rspamd_re_cache_quark(), 0,
+                       "unknown hyperscan file");
+
        return FALSE;
 #endif
 }