diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-07-24 08:13:45 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-07-24 08:13:45 +0100 |
commit | 6b71fcb72fce2945cca43cc2acc141b507655273 (patch) | |
tree | 66b21dc2ce49ad60eea6eb01ab18a2fbbb0a84bf | |
parent | 55159a5a8ef66e1a05fd93095623d90056c22fcd (diff) | |
download | rspamd-6b71fcb72fce2945cca43cc2acc141b507655273.tar.gz rspamd-6b71fcb72fce2945cca43cc2acc141b507655273.zip |
[Rework] Run post-loads when all initialization is completed
-rw-r--r-- | src/controller.c | 6 | ||||
-rw-r--r-- | src/fuzzy_storage.c | 3 | ||||
-rw-r--r-- | src/hs_helper.c | 3 | ||||
-rw-r--r-- | src/libserver/worker_util.c | 8 | ||||
-rw-r--r-- | src/libserver/worker_util.h | 2 | ||||
-rw-r--r-- | src/log_helper.c | 5 | ||||
-rw-r--r-- | src/lua_worker.c | 8 | ||||
-rw-r--r-- | src/rspamd_proxy.c | 5 | ||||
-rw-r--r-- | src/worker.c | 4 |
9 files changed, 20 insertions, 24 deletions
diff --git a/src/controller.c b/src/controller.c index 2f6fef716..e3f4c5d3a 100644 --- a/src/controller.c +++ b/src/controller.c @@ -3605,8 +3605,7 @@ start_controller_worker (struct rspamd_worker *worker) ctx->ev_base = rspamd_prepare_worker (worker, "controller", - rspamd_controller_accept_socket, - TRUE); + rspamd_controller_accept_socket); msec_to_tv (ctx->timeout, &ctx->io_tv); ctx->start_time = time (NULL); @@ -3802,6 +3801,9 @@ start_controller_worker (struct rspamd_worker *worker) rspamd_map_watch (worker->srv->cfg, ctx->ev_base, ctx->resolver, FALSE); } + rspamd_lua_run_postloads (ctx->cfg->lua_state, ctx->cfg, ctx->ev_base, worker); + + /* Start event loop */ event_base_loop (ctx->ev_base, 0); rspamd_worker_block_signals (); diff --git a/src/fuzzy_storage.c b/src/fuzzy_storage.c index 41f734593..47b76fb9b 100644 --- a/src/fuzzy_storage.c +++ b/src/fuzzy_storage.c @@ -2713,8 +2713,7 @@ start_fuzzy (struct rspamd_worker *worker) ctx->ev_base = rspamd_prepare_worker (worker, "fuzzy", - NULL, - FALSE); + NULL); ctx->peer_fd = -1; ctx->worker = worker; ctx->cfg = worker->srv->cfg; diff --git a/src/hs_helper.c b/src/hs_helper.c index 0031f029d..8e63469b1 100644 --- a/src/hs_helper.c +++ b/src/hs_helper.c @@ -290,8 +290,7 @@ start_hs_helper (struct rspamd_worker *worker) ctx->ev_base = rspamd_prepare_worker (worker, "hs_helper", - NULL, - FALSE); + NULL); if (!rspamd_rs_compile (ctx, worker, FALSE)) { /* Tell main not to respawn more workers */ diff --git a/src/libserver/worker_util.c b/src/libserver/worker_util.c index 9dfb6d5e6..1fd6c3555 100644 --- a/src/libserver/worker_util.c +++ b/src/libserver/worker_util.c @@ -257,7 +257,7 @@ rspamd_worker_init_signals (struct rspamd_worker *worker, struct event_base *bas struct event_base * rspamd_prepare_worker (struct rspamd_worker *worker, const char *name, - void (*accept_handler)(int, short, void *), gboolean load_lua) + void (*accept_handler)(int, short, void *)) { struct event_base *ev_base; struct event *accept_events; @@ -305,12 +305,6 @@ rspamd_prepare_worker (struct rspamd_worker *worker, const char *name, } } - if (load_lua) { - struct rspamd_config *cfg = worker->srv->cfg; - - rspamd_lua_run_postloads (cfg->lua_state, cfg, ev_base, worker); - } - return ev_base; } diff --git a/src/libserver/worker_util.h b/src/libserver/worker_util.h index 1fc4565cb..d8decbac8 100644 --- a/src/libserver/worker_util.h +++ b/src/libserver/worker_util.h @@ -40,7 +40,7 @@ struct rspamd_worker_signal_handler; */ struct event_base * rspamd_prepare_worker (struct rspamd_worker *worker, const char *name, - void (*accept_handler)(int, short, void *), gboolean load_lua); + void (*accept_handler)(int, short, void *)); /** * Set special signal handler for a worker diff --git a/src/log_helper.c b/src/log_helper.c index 84e485045..9800ab9d3 100644 --- a/src/log_helper.c +++ b/src/log_helper.c @@ -190,8 +190,7 @@ start_log_helper (struct rspamd_worker *worker) ctx->ev_base = rspamd_prepare_worker (worker, "log_helper", - NULL, - TRUE); + NULL); ctx->cfg = worker->srv->cfg; ctx->scripts = worker->cf->scripts; ctx->L = ctx->cfg->lua_state; @@ -222,6 +221,8 @@ start_log_helper (struct rspamd_worker *worker) rspamd_srv_send_command (worker, ctx->ev_base, &srv_cmd, ctx->pair[1], rspamd_log_helper_reply_handler, ctx); rspamd_mempool_unlock_mutex (worker->srv->start_mtx); + rspamd_lua_run_postloads (ctx->cfg->lua_state, ctx->cfg, ctx->ev_base, + worker); event_base_loop (ctx->ev_base, 0); close (ctx->pair[0]); rspamd_worker_block_signals (); diff --git a/src/lua_worker.c b/src/lua_worker.c index e5733058a..d5b651aaf 100644 --- a/src/lua_worker.c +++ b/src/lua_worker.c @@ -352,8 +352,7 @@ start_lua_worker (struct rspamd_worker *worker) ctx->ev_base = rspamd_prepare_worker (worker, "lua_worker", - lua_accept_socket, - TRUE); + lua_accept_socket); L = worker->srv->cfg->lua_state; ctx->L = L; @@ -392,9 +391,8 @@ start_lua_worker (struct rspamd_worker *worker) exit (EXIT_SUCCESS); } - /* Maps events */ - rspamd_map_watch (worker->srv->cfg, ctx->ev_base, ctx->resolver, 0); - + rspamd_lua_run_postloads (ctx->cfg->lua_state, ctx->cfg, ctx->ev_base, + worker); event_base_loop (ctx->ev_base, 0); rspamd_worker_block_signals (); diff --git a/src/rspamd_proxy.c b/src/rspamd_proxy.c index 7134c4b52..a2521fec1 100644 --- a/src/rspamd_proxy.c +++ b/src/rspamd_proxy.c @@ -2040,8 +2040,7 @@ start_rspamd_proxy (struct rspamd_worker *worker) { ctx->cfg = worker->srv->cfg; ctx->ev_base = rspamd_prepare_worker (worker, "rspamd_proxy", - proxy_accept_socket, - TRUE); + proxy_accept_socket); ctx->resolver = dns_resolver_init (worker->srv->logger, ctx->ev_base, @@ -2075,6 +2074,8 @@ start_rspamd_proxy (struct rspamd_worker *worker) { rspamd_milter_init_library (ctx->spam_header, ctx->sessions_cache, ctx->discard_on_reject); + rspamd_lua_run_postloads (ctx->cfg->lua_state, ctx->cfg, ctx->ev_base, + worker); event_base_loop (ctx->ev_base, 0); rspamd_worker_block_signals (); diff --git a/src/worker.c b/src/worker.c index c6e419e36..717e5451b 100644 --- a/src/worker.c +++ b/src/worker.c @@ -671,7 +671,7 @@ start_worker (struct rspamd_worker *worker) struct rspamd_worker_ctx *ctx = worker->ctx; ctx->cfg = worker->srv->cfg; - ctx->ev_base = rspamd_prepare_worker (worker, "normal", accept_socket, TRUE); + ctx->ev_base = rspamd_prepare_worker (worker, "normal", accept_socket); msec_to_tv (ctx->timeout, &ctx->io_tv); rspamd_symbols_cache_start_refresh (worker->srv->cfg->cache, ctx->ev_base, worker); @@ -686,6 +686,8 @@ start_worker (struct rspamd_worker *worker) /* XXX: stupid default */ ctx->keys_cache = rspamd_keypair_cache_new (256); rspamd_worker_init_scanner (worker, ctx->ev_base, ctx->resolver); + rspamd_lua_run_postloads (ctx->cfg->lua_state, ctx->cfg, ctx->ev_base, + worker); event_base_loop (ctx->ev_base, 0); rspamd_worker_block_signals (); |