G_DIR_SEPARATOR, re_class->hash);
if (rspamd_re_cache_is_valid_hyperscan_file (cache, path)) {
- msg_info_re_cache ("skip already valid file for re class '%s'",
+ msg_debug_re_cache ("load hyperscan database from '%s'",
re_class->hash);
fd = open (path, O_RDONLY);
* specify that they should be matched using hyperscan
*/
for (i = 0; i < n; i ++) {
- g_assert ((gint)cache->re->len < hs_ids[i] && hs_ids[i] >= 0);
+ g_assert ((gint)cache->re->len > hs_ids[i] && hs_ids[i] >= 0);
elt = g_ptr_array_index (cache->re, hs_ids[i]);
elt->match_type = RSPAMD_RE_CACHE_HYPERSCAN;
}
* Rspamd worker implementation
*/
+#include <libserver/rspamd_control.h>
#include "config.h"
#include "libutil/util.h"
#include "libutil/map.h"
#include "keypairs_cache.h"
#include "libstat/stat_api.h"
#include "libserver/worker_util.h"
+#include "libserver/rspamd_control.h"
#include "lua/lua_common.h"
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)
{
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 ();