From 562fac4c3c2045cc3a65f0bb37db0a7b2d47c6cb Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Fri, 21 Jun 2019 13:46:01 +0100 Subject: [Minor] Load hyperscan cache in controller as well --- src/libserver/worker_util.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'src/libserver/worker_util.c') diff --git a/src/libserver/worker_util.c b/src/libserver/worker_util.c index 4072b9598..5c5d41b90 100644 --- a/src/libserver/worker_util.c +++ b/src/libserver/worker_util.c @@ -1294,4 +1294,36 @@ rspamd_check_termination_clause (struct rspamd_main *rspamd_main, } return need_refork; -} \ No newline at end of file +} + +#ifdef WITH_HYPERSCAN +gboolean +rspamd_worker_hyperscan_ready (struct rspamd_main *rspamd_main, + struct rspamd_worker *worker, gint fd, + gint attached_fd, + struct rspamd_control_command *cmd, + gpointer ud) +{ + struct rspamd_control_reply rep; + struct rspamd_re_cache *cache = worker->srv->cfg->re_cache; + + memset (&rep, 0, sizeof (rep)); + rep.type = RSPAMD_CONTROL_HYPERSCAN_LOADED; + + if (!rspamd_re_cache_is_hs_loaded (cache) || cmd->cmd.hs_loaded.forced) { + msg_info ("loading hyperscan expressions after receiving compilation " + "notice: %s", + (!rspamd_re_cache_is_hs_loaded (cache)) ? + "new db" : "forced update"); + rep.reply.hs_loaded.status = rspamd_re_cache_load_hyperscan ( + worker->srv->cfg->re_cache, cmd->cmd.hs_loaded.cache_dir); + } + + if (write (fd, &rep, sizeof (rep)) != sizeof (rep)) { + msg_err ("cannot write reply to the control socket: %s", + strerror (errno)); + } + + return TRUE; +} +#endif \ No newline at end of file -- cgit v1.2.3