summaryrefslogtreecommitdiffstats
path: root/src/worker.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-12-08 18:35:05 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-12-08 18:35:05 +0000
commit801cf9058e61fa153908b064ca8495844f4e83ab (patch)
tree104ddce0be2462993e87e84a478db7daa4d223c7 /src/worker.c
parent8178bc554d0abe8a6cf95755a266859c84cfd786 (diff)
downloadrspamd-801cf9058e61fa153908b064ca8495844f4e83ab.tar.gz
rspamd-801cf9058e61fa153908b064ca8495844f4e83ab.zip
Implement hyperscan loading by receiving signal
Diffstat (limited to 'src/worker.c')
-rw-r--r--src/worker.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/worker.c b/src/worker.c
index e63624848..2598be415 100644
--- a/src/worker.c
+++ b/src/worker.c
@@ -26,6 +26,7 @@
* Rspamd worker implementation
*/
+#include <libserver/rspamd_control.h>
#include "config.h"
#include "libutil/util.h"
#include "libutil/map.h"
@@ -39,6 +40,7 @@
#include "keypairs_cache.h"
#include "libstat/stat_api.h"
#include "libserver/worker_util.h"
+#include "libserver/rspamd_control.h"
#include "lua/lua_common.h"
@@ -280,6 +282,31 @@ accept_socket (gint fd, short what, void *arg)
ctx->ev_base);
}
+#ifdef WITH_HYPERSCAN
+static gboolean
+rspamd_worker_hyperscan_ready (struct rspamd_main *rspamd_main,
+ struct rspamd_worker *worker, gint fd,
+ struct rspamd_control_command *cmd,
+ gpointer ud)
+{
+ struct rspamd_control_reply rep;
+
+ msg_info ("loading hyperscan expressions after receiving compilation notice");
+ memset (&rep, 0, sizeof (rep));
+ rep.type = RSPAMD_CONTROL_HYPERSCAN_LOADED;
+
+ 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
+
gpointer
init_worker (struct rspamd_config *cfg)
{
@@ -359,6 +386,11 @@ start_worker (struct rspamd_worker *worker)
ctx->keys_cache = rspamd_keypair_cache_new (256);
rspamd_stat_init (worker->srv->cfg);
+#ifdef WITH_HYPERSCAN
+ rspamd_control_worker_add_cmd_handler (worker, RSPAMD_CONTROL_HYPERSCAN_LOADED,
+ rspamd_worker_hyperscan_ready, ctx);
+#endif
+
event_base_loop (ctx->ev_base, 0);
rspamd_worker_block_signals ();