aboutsummaryrefslogtreecommitdiffstats
path: root/src/worker.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2023-07-26 10:49:23 +0100
committerVsevolod Stakhov <vsevolod@rspamd.com>2023-07-26 10:49:23 +0100
commit537a7180a0d5132c11636c4fd8b1450cd99d352c (patch)
treefb9f8c84955a411bdffbd6371ea32f2716fb3687 /src/worker.c
parent5fd7a90fdaa33f52c59bdb0ca84451e5c1e22365 (diff)
downloadrspamd-537a7180a0d5132c11636c4fd8b1450cd99d352c.tar.gz
rspamd-537a7180a0d5132c11636c4fd8b1450cd99d352c.zip
[Rework] Use clang-format to unify formatting in all sources
No meaningful changes.
Diffstat (limited to 'src/worker.c')
-rw-r--r--src/worker.c445
1 files changed, 222 insertions, 223 deletions
diff --git a/src/worker.c b/src/worker.c
index 4284e0b1b..8f99ad512 100644
--- a/src/worker.c
+++ b/src/worker.c
@@ -41,30 +41,30 @@
/* 60 seconds for worker's IO */
#define DEFAULT_WORKER_IO_TIMEOUT 60.0
-gpointer init_worker (struct rspamd_config *cfg);
-void start_worker (struct rspamd_worker *worker);
+gpointer init_worker(struct rspamd_config *cfg);
+void start_worker(struct rspamd_worker *worker);
worker_t normal_worker = {
- "normal", /* Name */
- init_worker, /* Init function */
- start_worker, /* Start function */
- RSPAMD_WORKER_HAS_SOCKET|RSPAMD_WORKER_KILLABLE|RSPAMD_WORKER_SCANNER,
- RSPAMD_WORKER_SOCKET_TCP, /* TCP socket */
- RSPAMD_WORKER_VER /* Version info */
+ "normal", /* Name */
+ init_worker, /* Init function */
+ start_worker, /* Start function */
+ RSPAMD_WORKER_HAS_SOCKET | RSPAMD_WORKER_KILLABLE | RSPAMD_WORKER_SCANNER,
+ RSPAMD_WORKER_SOCKET_TCP, /* TCP socket */
+ RSPAMD_WORKER_VER /* Version info */
};
-#define msg_err_ctx(...) rspamd_default_log_function(G_LOG_LEVEL_CRITICAL, \
- "worker", ctx->cfg->cfg_pool->tag.uid, \
- RSPAMD_LOG_FUNC, \
- __VA_ARGS__)
-#define msg_warn_ctx(...) rspamd_default_log_function (G_LOG_LEVEL_WARNING, \
- "worker", ctx->cfg->cfg_pool->tag.uid, \
- RSPAMD_LOG_FUNC, \
- __VA_ARGS__)
-#define msg_info_ctx(...) rspamd_default_log_function (G_LOG_LEVEL_INFO, \
- "worker", ctx->cfg->cfg_pool->tag.uid, \
- RSPAMD_LOG_FUNC, \
- __VA_ARGS__)
+#define msg_err_ctx(...) rspamd_default_log_function(G_LOG_LEVEL_CRITICAL, \
+ "worker", ctx->cfg->cfg_pool->tag.uid, \
+ RSPAMD_LOG_FUNC, \
+ __VA_ARGS__)
+#define msg_warn_ctx(...) rspamd_default_log_function(G_LOG_LEVEL_WARNING, \
+ "worker", ctx->cfg->cfg_pool->tag.uid, \
+ RSPAMD_LOG_FUNC, \
+ __VA_ARGS__)
+#define msg_info_ctx(...) rspamd_default_log_function(G_LOG_LEVEL_INFO, \
+ "worker", ctx->cfg->cfg_pool->tag.uid, \
+ RSPAMD_LOG_FUNC, \
+ __VA_ARGS__)
struct rspamd_worker_session {
gint64 magic;
@@ -79,18 +79,18 @@ struct rspamd_worker_session {
* Reduce number of tasks proceeded
*/
static void
-reduce_tasks_count (gpointer arg)
+reduce_tasks_count(gpointer arg)
{
struct rspamd_worker *worker = arg;
- worker->nconns --;
+ worker->nconns--;
if (worker->state == rspamd_worker_wait_connections && worker->nconns == 0) {
worker->state = rspamd_worker_wait_final_scripts;
- msg_info ("performing finishing actions");
+ msg_info("performing finishing actions");
- if (rspamd_worker_call_finish_handlers (worker)) {
+ if (rspamd_worker_call_finish_handlers(worker)) {
worker->state = rspamd_worker_wait_final_scripts;
}
else {
@@ -103,11 +103,11 @@ reduce_tasks_count (gpointer arg)
}
static gint
-rspamd_worker_body_handler (struct rspamd_http_connection *conn,
- struct rspamd_http_message *msg,
- const gchar *chunk, gsize len)
+rspamd_worker_body_handler(struct rspamd_http_connection *conn,
+ struct rspamd_http_message *msg,
+ const gchar *chunk, gsize len)
{
- struct rspamd_worker_session *session = (struct rspamd_worker_session *)conn->ud;
+ struct rspamd_worker_session *session = (struct rspamd_worker_session *) conn->ud;
struct rspamd_task *task;
struct rspamd_worker_ctx *ctx;
const rspamd_ftok_t *hv_tok;
@@ -116,26 +116,26 @@ rspamd_worker_body_handler (struct rspamd_http_connection *conn,
ctx = session->ctx;
/* Check debug */
- if ((hv_tok = rspamd_http_message_find_header (msg, "Memory")) != NULL) {
+ if ((hv_tok = rspamd_http_message_find_header(msg, "Memory")) != NULL) {
rspamd_ftok_t cmp;
- RSPAMD_FTOK_ASSIGN (&cmp, "debug");
+ RSPAMD_FTOK_ASSIGN(&cmp, "debug");
- if (rspamd_ftok_cmp (hv_tok, &cmp) == 0) {
+ if (rspamd_ftok_cmp(hv_tok, &cmp) == 0) {
debug_mempool = TRUE;
}
}
- task = rspamd_task_new (session->worker,
- session->ctx->cfg, NULL, session->ctx->lang_det,
- session->ctx->event_loop,
- debug_mempool);
+ task = rspamd_task_new(session->worker,
+ session->ctx->cfg, NULL, session->ctx->lang_det,
+ session->ctx->event_loop,
+ debug_mempool);
session->task = task;
- msg_info_task ("accepted connection from %s port %d, task ptr: %p",
- rspamd_inet_address_to_string (session->addr),
- rspamd_inet_address_get_port (session->addr),
- task);
+ msg_info_task("accepted connection from %s port %d, task ptr: %p",
+ rspamd_inet_address_to_string(session->addr),
+ rspamd_inet_address_get_port(session->addr),
+ task);
/* Copy some variables */
if (ctx->is_mime) {
@@ -156,21 +156,21 @@ rspamd_worker_body_handler (struct rspamd_http_connection *conn,
task->flags |= RSPAMD_TASK_FLAG_LEARN_AUTO;
session->worker->nconns++;
- rspamd_mempool_add_destructor (task->task_pool,
- (rspamd_mempool_destruct_t)reduce_tasks_count,
- session->worker);
+ rspamd_mempool_add_destructor(task->task_pool,
+ (rspamd_mempool_destruct_t) reduce_tasks_count,
+ session->worker);
/* Session memory is also now handled by task */
- rspamd_mempool_add_destructor (task->task_pool,
- (rspamd_mempool_destruct_t)g_free,
- session);
+ rspamd_mempool_add_destructor(task->task_pool,
+ (rspamd_mempool_destruct_t) g_free,
+ session);
/* Set up async session */
- task->s = rspamd_session_create (task->task_pool, rspamd_task_fin,
- NULL, (event_finalizer_t )rspamd_task_free, task);
+ task->s = rspamd_session_create(task->task_pool, rspamd_task_fin,
+ NULL, (event_finalizer_t) rspamd_task_free, task);
- if (!rspamd_protocol_handle_request (task, msg)) {
- msg_err_task ("cannot handle request: %e", task->err);
+ if (!rspamd_protocol_handle_request(task, msg)) {
+ msg_err_task("cannot handle request: %e", task->err);
task->flags |= RSPAMD_TASK_FLAG_SKIP;
}
else {
@@ -178,8 +178,8 @@ rspamd_worker_body_handler (struct rspamd_http_connection *conn,
task->flags |= RSPAMD_TASK_FLAG_SKIP;
}
else {
- if (!rspamd_task_load_message (task, msg, chunk, len)) {
- msg_err_task ("cannot load message: %e", task->err);
+ if (!rspamd_task_load_message(task, msg, chunk, len)) {
+ msg_err_task("cannot load message: %e", task->err);
task->flags |= RSPAMD_TASK_FLAG_SKIP;
}
}
@@ -188,29 +188,29 @@ rspamd_worker_body_handler (struct rspamd_http_connection *conn,
/* Set global timeout for the task */
if (!isnan(ctx->task_timeout) && ctx->task_timeout > 0.0) {
task->timeout_ev.data = task;
- ev_timer_init (&task->timeout_ev, rspamd_task_timeout,
- ctx->task_timeout,
- ctx->task_timeout);
- ev_set_priority (&task->timeout_ev, EV_MAXPRI);
- ev_timer_start (task->event_loop, &task->timeout_ev);
+ ev_timer_init(&task->timeout_ev, rspamd_task_timeout,
+ ctx->task_timeout,
+ ctx->task_timeout);
+ ev_set_priority(&task->timeout_ev, EV_MAXPRI);
+ ev_timer_start(task->event_loop, &task->timeout_ev);
}
/* Set socket guard */
task->guard_ev.data = task;
- ev_io_init (&task->guard_ev,
- rspamd_worker_guard_handler,
- task->sock, EV_READ);
- ev_io_start (task->event_loop, &task->guard_ev);
+ ev_io_init(&task->guard_ev,
+ rspamd_worker_guard_handler,
+ task->sock, EV_READ);
+ ev_io_start(task->event_loop, &task->guard_ev);
- rspamd_task_process (task, RSPAMD_TASK_PROCESS_ALL);
+ rspamd_task_process(task, RSPAMD_TASK_PROCESS_ALL);
return 0;
}
static void
-rspamd_worker_error_handler (struct rspamd_http_connection *conn, GError *err)
+rspamd_worker_error_handler(struct rspamd_http_connection *conn, GError *err)
{
- struct rspamd_worker_session *session = (struct rspamd_worker_session *)conn->ud;
+ struct rspamd_worker_session *session = (struct rspamd_worker_session *) conn->ud;
struct rspamd_task *task;
struct rspamd_http_message *msg;
rspamd_fstring_t *reply;
@@ -238,65 +238,65 @@ rspamd_worker_error_handler (struct rspamd_http_connection *conn, GError *err)
task = session->task;
}
else {
- task = (struct rspamd_task *)conn->ud;
+ task = (struct rspamd_task *) conn->ud;
}
if (task) {
- msg_info_task ("abnormally closing connection from: %s, error: %e",
- rspamd_inet_address_to_string_pretty (task->client_addr), err);
+ msg_info_task("abnormally closing connection from: %s, error: %e",
+ rspamd_inet_address_to_string_pretty(task->client_addr), err);
if (task->processed_stages & RSPAMD_TASK_STAGE_REPLIED) {
/* Terminate session immediately */
- rspamd_session_destroy (task->s);
+ rspamd_session_destroy(task->s);
}
else {
task->processed_stages |= RSPAMD_TASK_STAGE_REPLIED;
- msg = rspamd_http_new_message (HTTP_RESPONSE);
+ msg = rspamd_http_new_message(HTTP_RESPONSE);
if (err) {
- msg->status = rspamd_fstring_new_init (err->message,
- strlen (err->message));
+ msg->status = rspamd_fstring_new_init(err->message,
+ strlen(err->message));
msg->code = err->code;
}
else {
- msg->status = rspamd_fstring_new_init ("Internal error",
- strlen ("Internal error"));
+ msg->status = rspamd_fstring_new_init("Internal error",
+ strlen("Internal error"));
msg->code = 500;
}
- msg->date = time (NULL);
+ msg->date = time(NULL);
- reply = rspamd_fstring_sized_new (msg->status->len + 16);
- rspamd_printf_fstring (&reply, "{\"error\":\"%V\"}", msg->status);
- rspamd_http_message_set_body_from_fstring_steal (msg, reply);
- rspamd_http_connection_reset (task->http_conn);
+ reply = rspamd_fstring_sized_new(msg->status->len + 16);
+ rspamd_printf_fstring(&reply, "{\"error\":\"%V\"}", msg->status);
+ rspamd_http_message_set_body_from_fstring_steal(msg, reply);
+ rspamd_http_connection_reset(task->http_conn);
/* Use a shorter timeout for writing reply */
- rspamd_http_connection_write_message (task->http_conn,
- msg,
- NULL,
- "application/json",
- task,
- session->ctx->timeout / 10.0);
+ rspamd_http_connection_write_message(task->http_conn,
+ msg,
+ NULL,
+ "application/json",
+ task,
+ session->ctx->timeout / 10.0);
}
}
else {
/* If there was no task, then session is unmanaged */
- msg_info ("no data received from: %s, error: %e",
- rspamd_inet_address_to_string_pretty (session->addr), err);
- rspamd_http_connection_reset (session->http_conn);
- rspamd_http_connection_unref (session->http_conn);
- rspamd_inet_address_free (session->addr);
- close (session->fd);
- g_free (session);
+ msg_info("no data received from: %s, error: %e",
+ rspamd_inet_address_to_string_pretty(session->addr), err);
+ rspamd_http_connection_reset(session->http_conn);
+ rspamd_http_connection_unref(session->http_conn);
+ rspamd_inet_address_free(session->addr);
+ close(session->fd);
+ g_free(session);
}
}
static gint
-rspamd_worker_finish_handler (struct rspamd_http_connection *conn,
- struct rspamd_http_message *msg)
+rspamd_worker_finish_handler(struct rspamd_http_connection *conn,
+ struct rspamd_http_message *msg)
{
- struct rspamd_worker_session *session = (struct rspamd_worker_session *)conn->ud;
+ struct rspamd_worker_session *session = (struct rspamd_worker_session *) conn->ud;
struct rspamd_task *task;
/* Read the comment to rspamd_worker_error_handler */
@@ -305,29 +305,29 @@ rspamd_worker_finish_handler (struct rspamd_http_connection *conn,
task = session->task;
}
else {
- task = (struct rspamd_task *)conn->ud;
+ task = (struct rspamd_task *) conn->ud;
}
if (task) {
if (task->processed_stages & RSPAMD_TASK_STAGE_REPLIED) {
/* We are done here */
- msg_debug_task ("normally closing connection from: %s",
- rspamd_inet_address_to_string (task->client_addr));
- rspamd_session_destroy (task->s);
+ msg_debug_task("normally closing connection from: %s",
+ rspamd_inet_address_to_string(task->client_addr));
+ rspamd_session_destroy(task->s);
}
else if (task->processed_stages & RSPAMD_TASK_STAGE_DONE) {
- rspamd_session_pending (task->s);
+ rspamd_session_pending(task->s);
}
}
else {
/* If there was no task, then session is unmanaged */
- msg_info ("no data received from: %s, closing connection",
- rspamd_inet_address_to_string_pretty (session->addr));
- rspamd_inet_address_free (session->addr);
- rspamd_http_connection_reset (session->http_conn);
- rspamd_http_connection_unref (session->http_conn);
- close (session->fd);
- g_free (session);
+ msg_info("no data received from: %s, closing connection",
+ rspamd_inet_address_to_string_pretty(session->addr));
+ rspamd_inet_address_free(session->addr);
+ rspamd_http_connection_reset(session->http_conn);
+ rspamd_http_connection_unref(session->http_conn);
+ close(session->fd);
+ g_free(session);
}
return 0;
@@ -337,7 +337,7 @@ rspamd_worker_finish_handler (struct rspamd_http_connection *conn,
* Accept new connection and construct task
*/
static void
-accept_socket (EV_P_ ev_io *w, int revents)
+accept_socket(EV_P_ ev_io *w, int revents)
{
struct rspamd_worker *worker = (struct rspamd_worker *) w->data;
struct rspamd_worker_ctx *ctx;
@@ -348,66 +348,66 @@ accept_socket (EV_P_ ev_io *w, int revents)
ctx = worker->ctx;
if (ctx->max_tasks != 0 && worker->nconns > ctx->max_tasks) {
- msg_info_ctx ("current tasks is now: %uD while maximum is: %uD",
- worker->nconns,
- ctx->max_tasks);
+ msg_info_ctx("current tasks is now: %uD while maximum is: %uD",
+ worker->nconns,
+ ctx->max_tasks);
return;
}
if ((nfd =
- rspamd_accept_from_socket (w->fd, &addr,
- rspamd_worker_throttle_accept_events, worker->accept_events)) == -1) {
- msg_warn_ctx ("accept failed: %s", strerror (errno));
+ rspamd_accept_from_socket(w->fd, &addr,
+ rspamd_worker_throttle_accept_events, worker->accept_events)) == -1) {
+ msg_warn_ctx("accept failed: %s", strerror(errno));
return;
}
/* Check for EAGAIN */
if (nfd == 0) {
- rspamd_inet_address_free (addr);
+ rspamd_inet_address_free(addr);
return;
}
- session = g_malloc0 (sizeof (*session));
+ session = g_malloc0(sizeof(*session));
session->magic = G_MAXINT64;
session->addr = addr;
session->fd = nfd;
session->ctx = ctx;
session->worker = worker;
- if (ctx->encrypted_only && !rspamd_inet_address_is_local (addr)) {
+ if (ctx->encrypted_only && !rspamd_inet_address_is_local(addr)) {
http_opts = RSPAMD_HTTP_REQUIRE_ENCRYPTION;
}
- session->http_conn = rspamd_http_connection_new_server (
- ctx->http_ctx,
- nfd,
- rspamd_worker_body_handler,
- rspamd_worker_error_handler,
- rspamd_worker_finish_handler,
- http_opts);
+ session->http_conn = rspamd_http_connection_new_server(
+ ctx->http_ctx,
+ nfd,
+ rspamd_worker_body_handler,
+ rspamd_worker_error_handler,
+ rspamd_worker_finish_handler,
+ http_opts);
worker->srv->stat->connections_count++;
- rspamd_http_connection_set_max_size (session->http_conn,
- ctx->cfg->max_message);
+ rspamd_http_connection_set_max_size(session->http_conn,
+ ctx->cfg->max_message);
if (ctx->key) {
- rspamd_http_connection_set_key (session->http_conn, ctx->key);
+ rspamd_http_connection_set_key(session->http_conn, ctx->key);
}
- rspamd_http_connection_read_message (session->http_conn,
- session,
- ctx->timeout);
+ rspamd_http_connection_read_message(session->http_conn,
+ session,
+ ctx->timeout);
}
gpointer
-init_worker (struct rspamd_config *cfg)
+init_worker(struct rspamd_config *cfg)
{
struct rspamd_worker_ctx *ctx;
GQuark type;
- type = g_quark_try_string ("normal");
- ctx = rspamd_mempool_alloc0 (cfg->cfg_pool,
- sizeof (struct rspamd_worker_ctx));
+ type = g_quark_try_string("normal");
+ ctx = rspamd_mempool_alloc0(cfg->cfg_pool,
+ sizeof(struct rspamd_worker_ctx));
ctx->magic = rspamd_worker_magic;
ctx->is_mime = TRUE;
@@ -415,64 +415,64 @@ init_worker (struct rspamd_config *cfg)
ctx->cfg = cfg;
ctx->task_timeout = NAN;
- rspamd_rcl_register_worker_option (cfg,
- type,
- "mime",
- rspamd_rcl_parse_struct_boolean,
- ctx,
- G_STRUCT_OFFSET (struct rspamd_worker_ctx, is_mime),
- 0,
- "Set to `false` if this worker is intended to work with non-MIME messages");
-
- rspamd_rcl_register_worker_option (cfg,
- type,
- "encrypted_only",
- rspamd_rcl_parse_struct_boolean,
- ctx,
- G_STRUCT_OFFSET (struct rspamd_worker_ctx, encrypted_only),
- 0,
- "Allow only encrypted connections");
-
-
- rspamd_rcl_register_worker_option (cfg,
- type,
- "timeout",
- rspamd_rcl_parse_struct_time,
- ctx,
- G_STRUCT_OFFSET (struct rspamd_worker_ctx,
- timeout),
- RSPAMD_CL_FLAG_TIME_FLOAT,
- "Protocol IO timeout");
-
- rspamd_rcl_register_worker_option (cfg,
- type,
- "task_timeout",
- rspamd_rcl_parse_struct_time,
- ctx,
- G_STRUCT_OFFSET (struct rspamd_worker_ctx,
- task_timeout),
- RSPAMD_CL_FLAG_TIME_FLOAT,
- "Maximum task processing time, default: 8.0 seconds");
-
- rspamd_rcl_register_worker_option (cfg,
- type,
- "max_tasks",
- rspamd_rcl_parse_struct_integer,
- ctx,
- G_STRUCT_OFFSET (struct rspamd_worker_ctx,
- max_tasks),
- RSPAMD_CL_FLAG_INT_32,
- "Maximum count of parallel tasks processed by a single worker process");
-
- rspamd_rcl_register_worker_option (cfg,
- type,
- "keypair",
- rspamd_rcl_parse_struct_keypair,
- ctx,
- G_STRUCT_OFFSET (struct rspamd_worker_ctx,
- key),
- 0,
- "Encryption keypair");
+ rspamd_rcl_register_worker_option(cfg,
+ type,
+ "mime",
+ rspamd_rcl_parse_struct_boolean,
+ ctx,
+ G_STRUCT_OFFSET(struct rspamd_worker_ctx, is_mime),
+ 0,
+ "Set to `false` if this worker is intended to work with non-MIME messages");
+
+ rspamd_rcl_register_worker_option(cfg,
+ type,
+ "encrypted_only",
+ rspamd_rcl_parse_struct_boolean,
+ ctx,
+ G_STRUCT_OFFSET(struct rspamd_worker_ctx, encrypted_only),
+ 0,
+ "Allow only encrypted connections");
+
+
+ rspamd_rcl_register_worker_option(cfg,
+ type,
+ "timeout",
+ rspamd_rcl_parse_struct_time,
+ ctx,
+ G_STRUCT_OFFSET(struct rspamd_worker_ctx,
+ timeout),
+ RSPAMD_CL_FLAG_TIME_FLOAT,
+ "Protocol IO timeout");
+
+ rspamd_rcl_register_worker_option(cfg,
+ type,
+ "task_timeout",
+ rspamd_rcl_parse_struct_time,
+ ctx,
+ G_STRUCT_OFFSET(struct rspamd_worker_ctx,
+ task_timeout),
+ RSPAMD_CL_FLAG_TIME_FLOAT,
+ "Maximum task processing time, default: 8.0 seconds");
+
+ rspamd_rcl_register_worker_option(cfg,
+ type,
+ "max_tasks",
+ rspamd_rcl_parse_struct_integer,
+ ctx,
+ G_STRUCT_OFFSET(struct rspamd_worker_ctx,
+ max_tasks),
+ RSPAMD_CL_FLAG_INT_32,
+ "Maximum count of parallel tasks processed by a single worker process");
+
+ rspamd_rcl_register_worker_option(cfg,
+ type,
+ "keypair",
+ rspamd_rcl_parse_struct_keypair,
+ ctx,
+ G_STRUCT_OFFSET(struct rspamd_worker_ctx,
+ key),
+ 0,
+ "Encryption keypair");
return ctx;
}
@@ -480,59 +480,58 @@ init_worker (struct rspamd_config *cfg)
/*
* Start worker process
*/
-__attribute__((noreturn))
-void
-start_worker (struct rspamd_worker *worker)
+__attribute__((noreturn)) void
+start_worker(struct rspamd_worker *worker)
{
struct rspamd_worker_ctx *ctx = worker->ctx;
gboolean is_controller = FALSE;
- g_assert (rspamd_worker_check_context (worker->ctx, rspamd_worker_magic));
+ g_assert(rspamd_worker_check_context(worker->ctx, rspamd_worker_magic));
ctx->cfg = worker->srv->cfg;
- ctx->event_loop = rspamd_prepare_worker (worker, "normal", accept_socket);
- rspamd_symcache_start_refresh (worker->srv->cfg->cache, ctx->event_loop,
- worker);
+ ctx->event_loop = rspamd_prepare_worker(worker, "normal", accept_socket);
+ rspamd_symcache_start_refresh(worker->srv->cfg->cache, ctx->event_loop,
+ worker);
ctx->task_timeout = rspamd_worker_check_and_adjust_timeout(ctx->cfg, ctx->task_timeout);
- ctx->resolver = rspamd_dns_resolver_init (worker->srv->logger,
- ctx->event_loop,
- worker->srv->cfg);
- rspamd_upstreams_library_config (worker->srv->cfg, ctx->cfg->ups_ctx,
- ctx->event_loop, ctx->resolver->r);
+ ctx->resolver = rspamd_dns_resolver_init(worker->srv->logger,
+ ctx->event_loop,
+ worker->srv->cfg);
+ rspamd_upstreams_library_config(worker->srv->cfg, ctx->cfg->ups_ctx,
+ ctx->event_loop, ctx->resolver->r);
- ctx->http_ctx = rspamd_http_context_create (ctx->cfg, ctx->event_loop,
- ctx->cfg->ups_ctx);
- rspamd_mempool_add_destructor (ctx->cfg->cfg_pool,
- (rspamd_mempool_destruct_t)rspamd_http_context_free,
- ctx->http_ctx);
- rspamd_worker_init_scanner (worker, ctx->event_loop, ctx->resolver,
- &ctx->lang_det);
+ ctx->http_ctx = rspamd_http_context_create(ctx->cfg, ctx->event_loop,
+ ctx->cfg->ups_ctx);
+ rspamd_mempool_add_destructor(ctx->cfg->cfg_pool,
+ (rspamd_mempool_destruct_t) rspamd_http_context_free,
+ ctx->http_ctx);
+ rspamd_worker_init_scanner(worker, ctx->event_loop, ctx->resolver,
+ &ctx->lang_det);
- is_controller = rspamd_worker_check_controller_presence (worker);
+ is_controller = rspamd_worker_check_controller_presence(worker);
if (is_controller) {
- rspamd_worker_init_controller (worker, NULL);
+ rspamd_worker_init_controller(worker, NULL);
}
else {
- rspamd_map_watch (worker->srv->cfg, ctx->event_loop, ctx->resolver,
- worker, RSPAMD_MAP_WATCH_SCANNER);
+ rspamd_map_watch(worker->srv->cfg, ctx->event_loop, ctx->resolver,
+ worker, RSPAMD_MAP_WATCH_SCANNER);
}
- rspamd_lua_run_postloads (ctx->cfg->lua_state, ctx->cfg, ctx->event_loop,
- worker);
+ rspamd_lua_run_postloads(ctx->cfg->lua_state, ctx->cfg, ctx->event_loop,
+ worker);
- ev_loop (ctx->event_loop, 0);
- rspamd_worker_block_signals ();
+ ev_loop(ctx->event_loop, 0);
+ rspamd_worker_block_signals();
if (is_controller) {
- rspamd_controller_on_terminate (worker, NULL);
+ rspamd_controller_on_terminate(worker, NULL);
}
- rspamd_stat_close ();
- REF_RELEASE (ctx->cfg);
- rspamd_log_close (worker->srv->logger);
- rspamd_unset_crash_handler (worker->srv);
+ rspamd_stat_close();
+ REF_RELEASE(ctx->cfg);
+ rspamd_log_close(worker->srv->logger);
+ rspamd_unset_crash_handler(worker->srv);
- exit (EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}