]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Load hyperscan cache in controller as well
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 21 Jun 2019 12:46:01 +0000 (13:46 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 22 Jun 2019 09:57:29 +0000 (10:57 +0100)
src/controller.c
src/libserver/rspamd_control.c
src/libserver/worker_util.c
src/libserver/worker_util.h
src/rspamd_proxy.c
src/worker.c

index f242699994822216ad2b554c6c3e7e1bcacef812..46c02d47ce9894cb0035d57d5f6a5a81b5f71d3f 100644 (file)
@@ -3910,6 +3910,13 @@ start_controller_worker (struct rspamd_worker *worker)
 
        rspamd_lua_run_postloads (ctx->cfg->lua_state, ctx->cfg, ctx->event_loop, worker);
 
+#ifdef WITH_HYPERSCAN
+       rspamd_control_worker_add_cmd_handler (worker,
+                       RSPAMD_CONTROL_HYPERSCAN_LOADED,
+                       rspamd_worker_hyperscan_ready,
+                       NULL);
+#endif
+
        /* Start event loop */
        ev_loop (ctx->event_loop, 0);
        rspamd_worker_block_signals ();
index 1d161f6bc9fb7ff6b539317a2e652d8ee521f2d5..257c743ace1b2094e6fb18c57767e63237d962c1 100644 (file)
@@ -794,6 +794,7 @@ rspamd_control_handle_on_fork (struct rspamd_srv_command *cmd,
        }
 }
 
+
 static void
 rspamd_srv_handler (EV_P_ ev_io *w, int revents)
 {
index 4072b959876b1e34cc74aded9113fc8b0d652b6f..5c5d41b9012515f8f8bd97e0a426af537548eea1 100644 (file)
@@ -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
index cafe1608fd3f5863d03a193f97ea8d18ddb34639..49bbda62b9d11b118a25b3395ed3598e82def2dd 100644 (file)
@@ -223,6 +223,15 @@ void rspamd_worker_throttle_accept_events (gint sock, void *data);
 gboolean rspamd_check_termination_clause (struct rspamd_main *rspamd_main,
                struct rspamd_worker *wrk, int status);
 
+#ifdef WITH_HYPERSCAN
+struct rspamd_control_command;
+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);
+#endif
+
 #define msg_err_main(...) rspamd_default_log_function (G_LOG_LEVEL_CRITICAL, \
         rspamd_main->server_pool->tag.tagname, rspamd_main->server_pool->tag.uid, \
         G_STRFUNC, \
index b14bd086aa6fbb42f29285561d758549b18e3cd1..9122df514bd0d5d92170840778f77c502f8d8dc5 100644 (file)
@@ -2158,6 +2158,7 @@ start_rspamd_proxy (struct rspamd_worker *worker)
                /* Additional initialisation needed */
                rspamd_worker_init_scanner (worker, ctx->event_loop, ctx->resolver,
                                &ctx->lang_det);
+
        }
 
        if (worker->srv->cfg->enable_sessions_cache) {
index ad0782b1716792abb608e2c7029a233f6a17c0e6..446de079909dc18a9829199dcea614c73540e45a 100644 (file)
@@ -407,38 +407,6 @@ accept_socket (EV_P_ ev_io *w, int revents)
                        ctx->timeout);
 }
 
-#ifdef WITH_HYPERSCAN
-static 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
-
 static gboolean
 rspamd_worker_log_pipe_handler (struct rspamd_main *rspamd_main,
                struct rspamd_worker *worker, gint fd,