From: Vsevolod Stakhov Date: Mon, 19 Jun 2017 07:15:52 +0000 (+0100) Subject: [Feature] Allow to disable specific workers in the config X-Git-Tag: 1.6.2~101 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=8fb06a8fe1ec7e3c96baa98085b7da6bbb07db03;p=rspamd.git [Feature] Allow to disable specific workers in the config --- diff --git a/conf/dmarc_whitelist.inc b/conf/dmarc_whitelist.inc index 9705635a4..09392a34f 100644 --- a/conf/dmarc_whitelist.inc +++ b/conf/dmarc_whitelist.inc @@ -25,6 +25,7 @@ force.com hh.ru instagram.com linkedin.com +livejournal.com mackeeper.com mercadolibre.com.ar mercadolivre.com.br diff --git a/src/libserver/cfg_file.h b/src/libserver/cfg_file.h index 89f4f0fde..3c5fe93fb 100644 --- a/src/libserver/cfg_file.h +++ b/src/libserver/cfg_file.h @@ -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; }; diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c index d8fc1c764..bf3a1779f 100644 --- a/src/libserver/cfg_rcl.c +++ b/src/libserver/cfg_rcl.c @@ -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 diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c index 2791c28d4..4966c37d6 100644 --- a/src/libserver/cfg_utils.c +++ b/src/libserver/cfg_utils.c @@ -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, diff --git a/src/rspamd.c b/src/rspamd.c index 828720cae..080ceef6c 100644 --- a/src/rspamd.c +++ b/src/rspamd.c @@ -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); }