diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-06-09 21:39:56 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-06-09 21:39:56 +0100 |
commit | 25584ee22ca2e17834a4aac2bf8f56f44273646b (patch) | |
tree | 457d400292f750f922a2d279ff55242b3be3d276 | |
parent | 9f292ddb10e2e87c08c3caa6478fffb13243d6d1 (diff) | |
download | rspamd-25584ee22ca2e17834a4aac2bf8f56f44273646b.tar.gz rspamd-25584ee22ca2e17834a4aac2bf8f56f44273646b.zip |
[Minor] Add dedicated_update_worker for fuzzy worker
-rw-r--r-- | src/fuzzy_storage.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/fuzzy_storage.c b/src/fuzzy_storage.c index c0a6f9daa..588e4a137 100644 --- a/src/fuzzy_storage.c +++ b/src/fuzzy_storage.c @@ -159,6 +159,7 @@ struct rspamd_fuzzy_storage_ctx { GHashTable *keys; gboolean encrypted_only; gboolean read_only; + gboolean dedicated_update_worker; struct rspamd_keypair_cache *keypair_cache; struct rspamd_http_context *http_ctx; rspamd_lru_hash_t *errors_ips; @@ -1980,6 +1981,14 @@ init_fuzzy (struct rspamd_config *cfg) G_STRUCT_OFFSET (struct rspamd_fuzzy_storage_ctx, encrypted_only), 0, "Allow encrypted requests only (and forbid all unknown keys or plaintext requests)"); + rspamd_rcl_register_worker_option (cfg, + type, + "dedicated_update_worker", + rspamd_rcl_parse_struct_boolean, + ctx, + G_STRUCT_OFFSET (struct rspamd_fuzzy_storage_ctx, dedicated_update_worker), + 0, + "Use worker 0 for updates only"); rspamd_rcl_register_worker_option (cfg, type, @@ -2215,6 +2224,24 @@ start_fuzzy (struct rspamd_worker *worker) sizeof (struct fuzzy_peer_cmd), 1024); rspamd_fuzzy_backend_start_update (ctx->backend, ctx->sync_timeout, rspamd_fuzzy_storage_periodic_callback, ctx); + + if (ctx->dedicated_update_worker && worker->cf->count > 1) { + msg_info_config ("stop serving clients request in dedicated update mode"); + rspamd_worker_stop_accept (worker); + + GList *cur = worker->cf->listen_socks; + + while (cur) { + struct rspamd_worker_listen_socket *ls = + (struct rspamd_worker_listen_socket *)cur->data; + + if (ls->fd != -1) { + close (ls->fd); + } + + cur = g_list_next (cur); + } + } } ctx->stat_ev.data = ctx; |