diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-06-21 13:46:01 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-06-22 10:57:29 +0100 |
commit | 562fac4c3c2045cc3a65f0bb37db0a7b2d47c6cb (patch) | |
tree | e52c5549f4574482854c4ef9084adc4f22ee68ee /src/libserver/worker_util.c | |
parent | d432fe8292abdceea2bae0b4a07ea5256247f92d (diff) | |
download | rspamd-562fac4c3c2045cc3a65f0bb37db0a7b2d47c6cb.tar.gz rspamd-562fac4c3c2045cc3a65f0bb37db0a7b2d47c6cb.zip |
[Minor] Load hyperscan cache in controller as well
Diffstat (limited to 'src/libserver/worker_util.c')
-rw-r--r-- | src/libserver/worker_util.c | 34 |
1 files changed, 33 insertions, 1 deletions
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 |