diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-12-24 14:34:03 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-12-24 14:34:03 +0000 |
commit | 20182643228a5a2608e8f36009a1cb316b13119c (patch) | |
tree | f3c21e3ef9ad2123dc2b60c804cad6f6b5124f27 /src/hs_helper.c | |
parent | 53631f158a5804d476010030ecf24f262ce15e74 (diff) | |
download | rspamd-20182643228a5a2608e8f36009a1cb316b13119c.tar.gz rspamd-20182643228a5a2608e8f36009a1cb316b13119c.zip |
On recompile remove all HS files, even correct ones
Diffstat (limited to 'src/hs_helper.c')
-rw-r--r-- | src/hs_helper.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/hs_helper.c b/src/hs_helper.c index 54517302c..1d49537c0 100644 --- a/src/hs_helper.c +++ b/src/hs_helper.c @@ -90,7 +90,7 @@ init_hs_helper (struct rspamd_config *cfg) * Clean */ static gboolean -rspamd_hs_helper_cleanup_dir (struct hs_helper_ctx *ctx) +rspamd_hs_helper_cleanup_dir (struct hs_helper_ctx *ctx, gboolean forced) { struct stat st; glob_t globbuf; @@ -113,7 +113,8 @@ 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, + if (forced || + !rspamd_re_cache_is_valid_hyperscan_file (ctx->cfg->re_cache, globbuf.gl_pathv[i], TRUE)) { if (unlink (globbuf.gl_pathv[i]) == -1) { msg_err ("cannot unlink %s: %s", globbuf.gl_pathv[i], @@ -135,13 +136,14 @@ rspamd_hs_helper_cleanup_dir (struct hs_helper_ctx *ctx) } static gboolean -rspamd_rs_compile (struct hs_helper_ctx *ctx, struct rspamd_worker *worker) +rspamd_rs_compile (struct hs_helper_ctx *ctx, struct rspamd_worker *worker, + gboolean forced) { GError *err = NULL; static struct rspamd_srv_command srv_cmd; gint ncompiled; - if (!rspamd_hs_helper_cleanup_dir (ctx)) { + if (!rspamd_hs_helper_cleanup_dir (ctx, forced)) { msg_warn ("cannot cleanup cache dir '%s'", ctx->hs_dir); } @@ -177,14 +179,16 @@ rspamd_hs_helper_reload (struct rspamd_main *rspamd_main, msg_info ("recompiling hyperscan expressions after receiving reload command"); memset (&rep, 0, sizeof (rep)); rep.type = RSPAMD_CONTROL_RECOMPILE; + rep.reply.recompile.status = 0; - rep.reply.recompile.status = rspamd_rs_compile (ctx, worker); - + /* We write reply before actual recompilation as it takes a lot of time */ if (write (fd, &rep, sizeof (rep)) != sizeof (rep)) { msg_err ("cannot write reply to the control socket: %s", strerror (errno)); } + rspamd_rs_compile (ctx, worker, TRUE); + return TRUE; } @@ -197,7 +201,7 @@ start_hs_helper (struct rspamd_worker *worker) "hs_helper", NULL); - if (!rspamd_rs_compile (ctx, worker)) { + if (!rspamd_rs_compile (ctx, worker, FALSE)) { /* Tell main not to respawn more workers */ exit (EXIT_SUCCESS); } |