]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Allow to disable specific workers in the config
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 19 Jun 2017 07:15:52 +0000 (08:15 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 19 Jun 2017 07:15:52 +0000 (08:15 +0100)
conf/dmarc_whitelist.inc
src/libserver/cfg_file.h
src/libserver/cfg_rcl.c
src/libserver/cfg_utils.c
src/rspamd.c

index 9705635a41fd8c0abe4420741cc37d2a783612ce..09392a34fe4e1f75dfae1e43c40008304c113f21 100644 (file)
@@ -25,6 +25,7 @@ force.com
 hh.ru
 instagram.com
 linkedin.com
+livejournal.com
 mackeeper.com
 mercadolibre.com.ar
 mercadolivre.com.br
index 89f4f0fde03d6a43e892ef92507e4133e2e80be3..3c5fe93fb88809aefe32c74fccff87347a947421 100644 (file)
@@ -198,6 +198,7 @@ struct rspamd_worker_conf {
        gpointer *ctx;                                  /**< worker's context                                                                   */
        ucl_object_t *options;                          /**< other worker's options                                                             */
        struct rspamd_worker_lua_script *scripts;       /**< registered lua scripts                                                             */
+       gboolean enabled;
        ref_entry_t ref;
 };
 
index d8fc1c764900b467ae58001163ac6a67e0d65f29..bf3a1779f01e3d19288cbe7352e73c8ae8cdd17f 100644 (file)
@@ -2400,6 +2400,12 @@ rspamd_rcl_config_init (struct rspamd_config *cfg)
                        G_STRUCT_OFFSET (struct rspamd_worker_conf, rlimit_maxcore),
                        RSPAMD_CL_FLAG_INT_32,
                        "Max size of core file in bytes");
+       rspamd_rcl_add_default_handler (sub,
+                       "enabled",
+                       rspamd_rcl_parse_struct_boolean,
+                       G_STRUCT_OFFSET (struct rspamd_worker_conf, enabled),
+                       0,
+                       "Enable or disable a worker (true by default)");
 
        /**
         * Modules handler
index 2791c28d49bc9e0ff5a9ee25134134fd59ba8d39..4966c37d64d57fad38573b79aa76054b4268b5c2 100644 (file)
@@ -987,6 +987,7 @@ rspamd_config_new_worker (struct rspamd_config *cfg,
 #endif
                c->rlimit_nofile = 0;
                c->rlimit_maxcore = 0;
+               c->enabled = TRUE;
 
                REF_INIT_RETAIN (c, rspamd_worker_conf_dtor);
                rspamd_mempool_add_destructor (cfg->cfg_pool,
index 828720cae8811664a71086943533295ea8709007..080ceef6cfc4bb77a3c5768910db374b82a1c0ec 100644 (file)
@@ -550,6 +550,14 @@ spawn_workers (struct rspamd_main *rspamd_main, struct event_base *ev_base)
                        msg_err_main ("type of worker is unspecified, skip spawning");
                }
                else {
+                       if (!cf->enabled) {
+                               msg_info_main ("worker of type %s is disabled in the config, "
+                                               "skip spawning", g_quark_to_string (cf->type));
+                               cur = g_list_next (cur);
+
+                               continue;
+                       }
+
                        if (cf->worker->flags & RSPAMD_WORKER_ALWAYS_START) {
                                g_ptr_array_add (seen_mandatory_workers, cf->worker);
                        }