]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Refactor worker task structure and API.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 21 Apr 2014 12:39:39 +0000 (13:39 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 21 Apr 2014 12:39:39 +0000 (13:39 +0100)
60 files changed:
src/CMakeLists.txt
src/classifiers/bayes.c
src/classifiers/classifiers.h
src/classifiers/winnow.c
src/controller.c
src/dkim.c
src/dkim.h
src/expressions.c
src/expressions.h
src/filter.c
src/filter.h
src/html.c
src/html.h
src/images.c
src/images.h
src/lmtp.c
src/lmtp_proto.c
src/lmtp_proto.h
src/lua/lua_cfg_file.c
src/lua/lua_classifier.c
src/lua/lua_common.c
src/lua/lua_common.h
src/lua/lua_config.c
src/lua/lua_http.c
src/lua/lua_redis.c
src/lua/lua_task.c
src/main.h
src/message.c
src/message.h
src/plugins/chartable.c
src/plugins/dkim_check.c
src/plugins/fuzzy_check.c
src/plugins/regexp.c
src/plugins/spf.c
src/plugins/surbl.c
src/plugins/surbl.h
src/protocol.c
src/protocol.h
src/roll_history.c
src/roll_history.h
src/settings.c
src/settings.h
src/smtp.h
src/smtp_utils.c
src/spf.c
src/spf.h
src/symbols_cache.c
src/symbols_cache.h
src/task.c [new file with mode: 0644]
src/task.h [new file with mode: 0644]
src/tokenizers/tokenizers.c
src/tokenizers/tokenizers.h
src/url.c
src/url.h
src/util.h
src/view.c
src/view.h
src/webui.c
src/worker.c
src/worker_util.c

index c8f4dfdcc038ec95428ab06e1f6541181e0ea90e..0e26481988d62f3770d469ca325b87e53abf3305 100644 (file)
@@ -35,6 +35,7 @@ SET(LIBRSPAMDSERVERSRC
                                statfile.c
                                statfile_sync.c
                                symbols_cache.c
+                               task.c
                                url.c
                                view.c)
                                
index 405336be72bef1fd6bfa047d84157b63d0f5234e..9c81b237039f36d7538fae702b2e83e3ffcb908e 100644 (file)
@@ -202,7 +202,7 @@ bayes_init (rspamd_mempool_t *pool, struct classifier_config *cfg)
 }
 
 gboolean
-bayes_classify (struct classifier_ctx* ctx, statfile_pool_t *pool, GTree *input, struct worker_task *task, lua_State *L)
+bayes_classify (struct classifier_ctx* ctx, statfile_pool_t *pool, GTree *input, struct rspamd_task *task, lua_State *L)
 {
        struct bayes_callback_data      data;
        gchar                           *value;
@@ -428,7 +428,7 @@ bayes_learn (struct classifier_ctx* ctx, statfile_pool_t *pool, const char *symb
 
 gboolean
 bayes_learn_spam (struct classifier_ctx* ctx, statfile_pool_t *pool,
-               GTree *input, struct worker_task *task, gboolean is_spam, lua_State *L, GError **err)
+               GTree *input, struct rspamd_task *task, gboolean is_spam, lua_State *L, GError **err)
 {
        struct bayes_callback_data      data;
        gchar                          *value;
@@ -528,7 +528,7 @@ bayes_learn_spam (struct classifier_ctx* ctx, statfile_pool_t *pool,
 }
 
 GList *
-bayes_weights (struct classifier_ctx* ctx, statfile_pool_t *pool, GTree *input, struct worker_task *task)
+bayes_weights (struct classifier_ctx* ctx, statfile_pool_t *pool, GTree *input, struct rspamd_task *task)
 {
        /* This function is unimplemented with new normalizer */
        return NULL;
index a316008cd0cf213c668524f665358cc5f1e6b323..3f7b755f41d7e9279d57b0fdeeccaf651fe9558f 100644 (file)
@@ -11,7 +11,7 @@
 #define ALPHA 0.0001
 
 struct classifier_config;
-struct worker_task;
+struct rspamd_task;
 
 struct classifier_ctx {
        rspamd_mempool_t *pool;
@@ -29,13 +29,13 @@ struct classify_weight {
 struct classifier {
        char *name;
        struct classifier_ctx* (*init_func)(rspamd_mempool_t *pool, struct classifier_config *cf);
-       gboolean (*classify_func)(struct classifier_ctx* ctx, statfile_pool_t *pool, GTree *input, struct worker_task *task, lua_State *L);
+       gboolean (*classify_func)(struct classifier_ctx* ctx, statfile_pool_t *pool, GTree *input, struct rspamd_task *task, lua_State *L);
        gboolean (*learn_func)(struct classifier_ctx* ctx, statfile_pool_t *pool,
                                                        const char *symbol, GTree *input, gboolean in_class,
                                                        double *sum, double multiplier, GError **err);
        gboolean (*learn_spam_func)(struct classifier_ctx* ctx, statfile_pool_t *pool,
-                                                               GTree *input, struct worker_task *task, gboolean is_spam, lua_State *L, GError **err);
-       GList* (*weights_func)(struct classifier_ctx* ctx, statfile_pool_t *pool, GTree *input, struct worker_task *task);
+                                                               GTree *input, struct rspamd_task *task, gboolean is_spam, lua_State *L, GError **err);
+       GList* (*weights_func)(struct classifier_ctx* ctx, statfile_pool_t *pool, GTree *input, struct rspamd_task *task);
 };
 
 /* Get classifier structure by name or return NULL if this name is not found */
@@ -43,21 +43,21 @@ struct classifier* get_classifier (const char *name);
 
 /* Winnow algorithm */
 struct classifier_ctx* winnow_init (rspamd_mempool_t *pool, struct classifier_config *cf);
-gboolean winnow_classify (struct classifier_ctx* ctx, statfile_pool_t *pool, GTree *input, struct worker_task *task, lua_State *L);
+gboolean winnow_classify (struct classifier_ctx* ctx, statfile_pool_t *pool, GTree *input, struct rspamd_task *task, lua_State *L);
 gboolean winnow_learn (struct classifier_ctx* ctx, statfile_pool_t *pool, const char *symbol, GTree *input,
                                gboolean in_class, double *sum, double multiplier, GError **err);
 gboolean winnow_learn_spam (struct classifier_ctx* ctx, statfile_pool_t *pool,
-                       GTree *input, struct worker_task *task, gboolean is_spam, lua_State *L, GError **err);
-GList *winnow_weights (struct classifier_ctx* ctx, statfile_pool_t *pool, GTree *input, struct worker_task *task);
+                       GTree *input, struct rspamd_task *task, gboolean is_spam, lua_State *L, GError **err);
+GList *winnow_weights (struct classifier_ctx* ctx, statfile_pool_t *pool, GTree *input, struct rspamd_task *task);
 
 /* Bayes algorithm */
 struct classifier_ctx* bayes_init (rspamd_mempool_t *pool, struct classifier_config *cf);
-gboolean bayes_classify (struct classifier_ctx* ctx, statfile_pool_t *pool, GTree *input, struct worker_task *task, lua_State *L);
+gboolean bayes_classify (struct classifier_ctx* ctx, statfile_pool_t *pool, GTree *input, struct rspamd_task *task, lua_State *L);
 gboolean bayes_learn (struct classifier_ctx* ctx, statfile_pool_t *pool, const char *symbol, GTree *input,
                                gboolean in_class, double *sum, double multiplier, GError **err);
 gboolean bayes_learn_spam (struct classifier_ctx* ctx, statfile_pool_t *pool,
-                       GTree *input, struct worker_task *task, gboolean is_spam, lua_State *L, GError **err);
-GList *bayes_weights (struct classifier_ctx* ctx, statfile_pool_t *pool, GTree *input, struct worker_task *task);
+                       GTree *input, struct rspamd_task *task, gboolean is_spam, lua_State *L, GError **err);
+GList *bayes_weights (struct classifier_ctx* ctx, statfile_pool_t *pool, GTree *input, struct rspamd_task *task);
 /* Array of all defined classifiers */
 extern struct classifier classifiers[];
 
index b9b5b7af944f2536ec88c4270e968276e20bcf58..91d06aaf4f679a9ed532883a06f083b87532fe76 100644 (file)
@@ -193,7 +193,7 @@ winnow_init (rspamd_mempool_t * pool, struct classifier_config *cfg)
 }
 
 gboolean
-winnow_classify (struct classifier_ctx *ctx, statfile_pool_t * pool, GTree * input, struct worker_task *task, lua_State *L)
+winnow_classify (struct classifier_ctx *ctx, statfile_pool_t * pool, GTree * input, struct rspamd_task *task, lua_State *L)
 {
        struct winnow_callback_data     data;
        char                           *sumbuf, *value;
@@ -282,7 +282,7 @@ winnow_classify (struct classifier_ctx *ctx, statfile_pool_t * pool, GTree * inp
 }
 
 GList *
-winnow_weights (struct classifier_ctx *ctx, statfile_pool_t * pool, GTree * input, struct worker_task *task)
+winnow_weights (struct classifier_ctx *ctx, statfile_pool_t * pool, GTree * input, struct rspamd_task *task)
 {
        struct winnow_callback_data     data;
        long double                     res = 0.;
@@ -593,7 +593,7 @@ end:
 
 gboolean
 winnow_learn_spam (struct classifier_ctx* ctx, statfile_pool_t *pool,
-               GTree *input, struct worker_task *task, gboolean is_spam, lua_State *L, GError **err)
+               GTree *input, struct rspamd_task *task, gboolean is_spam, lua_State *L, GError **err)
 {
        g_set_error (err,
                                        winnow_error_quark(),           /* error domain */
index 01f2a6a83af20ca74f46199f2dbca04e188f67c9..3b48bf5cd8135841b31e1690fbc4d0f9773a1940 100644 (file)
@@ -1279,7 +1279,7 @@ process_header (f_str_t *line, struct controller_session *session)
 static gboolean
 fin_learn_task (void *arg)
 {
-       struct worker_task             *task = (struct worker_task *) arg;
+       struct rspamd_task             *task = (struct rspamd_task *) arg;
 
        /* XXX: needs to be reworked */
 
@@ -1292,7 +1292,7 @@ fin_learn_task (void *arg)
 static void
 restore_learn_task (void *arg)
 {
-       struct worker_task             *task = (struct worker_task *) arg;
+       struct rspamd_task             *task = (struct rspamd_task *) arg;
 
        /* Special state */
 }
@@ -1305,7 +1305,7 @@ controller_read_socket (f_str_t * in, void *arg)
        gint                            len, i, r;
        gchar                          *s, **params, *cmd, out_buf[128];
        struct controller_command      *command;
-       struct worker_task             *task;
+       struct rspamd_task             *task;
        struct mime_text_part          *part;
        GList                          *cur = NULL;
        GTree                          *tokens = NULL;
index fd3807344c5821092bdbca3f325d3bf1b9e60369..c7c8a35e170c08baf4a6f7d5fc3f07516886d439 100644 (file)
@@ -1267,7 +1267,7 @@ rspamd_dkim_canonize_header_simple (rspamd_dkim_context_t *ctx, const gchar *hea
 }
 
 static gboolean
-rspamd_dkim_canonize_header (rspamd_dkim_context_t *ctx, struct worker_task *task, const gchar *header_name,
+rspamd_dkim_canonize_header (rspamd_dkim_context_t *ctx, struct rspamd_task *task, const gchar *header_name,
                guint count, gboolean is_sig)
 {
        struct raw_header                                                       *rh, *rh_iter;
@@ -1337,7 +1337,7 @@ rspamd_dkim_canonize_header (rspamd_dkim_context_t *ctx, struct worker_task *tas
  * @return
  */
 gint
-rspamd_dkim_check (rspamd_dkim_context_t *ctx, rspamd_dkim_key_t *key, struct worker_task *task)
+rspamd_dkim_check (rspamd_dkim_context_t *ctx, rspamd_dkim_key_t *key, struct rspamd_task *task)
 {
        const gchar                                                                     *p, *headers_end = NULL, *end, *body_end;
        gboolean                                                                         got_cr = FALSE, got_crlf = FALSE, got_lf = FALSE;
index 897c65fef8507bf37bd7eca5f362470a3822a514..29ec479b7d4dcf3fe22ff6a5a8713d5f02ed5cba 100644 (file)
@@ -164,7 +164,7 @@ typedef struct rspamd_dkim_key_s {
 }
 rspamd_dkim_key_t;
 
-struct worker_task;
+struct rspamd_task;
 
 /* Err MUST be freed if it is not NULL, key is allocated by slice allocator */
 typedef void (*dkim_key_handler_f)(rspamd_dkim_key_t *key, gsize keylen, rspamd_dkim_context_t *ctx, gpointer ud, GError *err);
@@ -196,7 +196,7 @@ gboolean rspamd_get_dkim_key (rspamd_dkim_context_t *ctx, struct rspamd_dns_reso
  * @param task task to check
  * @return
  */
-gint rspamd_dkim_check (rspamd_dkim_context_t *ctx, rspamd_dkim_key_t *key, struct worker_task *task);
+gint rspamd_dkim_check (rspamd_dkim_context_t *ctx, rspamd_dkim_key_t *key, struct rspamd_task *task);
 
 /**
  * Free DKIM key
index 8642251dac6b35b433181646aa57b5bae4b1ea73..5d19626bb58af7f81ba627e79ff8f16c888af124 100644 (file)
 #include "lua/lua_common.h"
 #include "diff.h"
 
-gboolean                        rspamd_compare_encoding (struct worker_task *task, GList * args, void *unused);
-gboolean                        rspamd_header_exists (struct worker_task *task, GList * args, void *unused);
-gboolean                        rspamd_parts_distance (struct worker_task *task, GList * args, void *unused);
-gboolean                        rspamd_recipients_distance (struct worker_task *task, GList * args, void *unused);
-gboolean                        rspamd_has_only_html_part (struct worker_task *task, GList * args, void *unused);
-gboolean                        rspamd_is_recipients_sorted (struct worker_task *task, GList * args, void *unused);
-gboolean                        rspamd_compare_transfer_encoding (struct worker_task *task, GList * args, void *unused);
-gboolean                        rspamd_is_html_balanced (struct worker_task *task, GList * args, void *unused);
-gboolean                        rspamd_has_html_tag (struct worker_task *task, GList * args, void *unused);
-gboolean                        rspamd_has_fake_html (struct worker_task *task, GList * args, void *unused);
+gboolean                        rspamd_compare_encoding (struct rspamd_task *task, GList * args, void *unused);
+gboolean                        rspamd_header_exists (struct rspamd_task *task, GList * args, void *unused);
+gboolean                        rspamd_parts_distance (struct rspamd_task *task, GList * args, void *unused);
+gboolean                        rspamd_recipients_distance (struct rspamd_task *task, GList * args, void *unused);
+gboolean                        rspamd_has_only_html_part (struct rspamd_task *task, GList * args, void *unused);
+gboolean                        rspamd_is_recipients_sorted (struct rspamd_task *task, GList * args, void *unused);
+gboolean                        rspamd_compare_transfer_encoding (struct rspamd_task *task, GList * args, void *unused);
+gboolean                        rspamd_is_html_balanced (struct rspamd_task *task, GList * args, void *unused);
+gboolean                        rspamd_has_html_tag (struct rspamd_task *task, GList * args, void *unused);
+gboolean                        rspamd_has_fake_html (struct rspamd_task *task, GList * args, void *unused);
 
 /*
  * List of internal functions of rspamd
@@ -792,7 +792,7 @@ parse_regexp (rspamd_mempool_t * pool, const gchar *line, gboolean raw_mode)
 }
 
 gboolean
-call_expression_function (struct expression_function * func, struct worker_task * task, lua_State *L)
+call_expression_function (struct expression_function * func, struct rspamd_task * task, lua_State *L)
 {
        struct _fl                     *selected, key;
 
@@ -808,7 +808,7 @@ call_expression_function (struct expression_function * func, struct worker_task
 }
 
 struct expression_argument     *
-get_function_arg (struct expression *expr, struct worker_task *task, gboolean want_string)
+get_function_arg (struct expression *expr, struct rspamd_task *task, gboolean want_string)
 {
        GQueue                         *stack;
        gsize                           cur, op1, op2;
@@ -922,7 +922,7 @@ register_expression_function (const gchar *name, rspamd_internal_func_t func, vo
 }
 
 gboolean
-rspamd_compare_encoding (struct worker_task *task, GList * args, void *unused)
+rspamd_compare_encoding (struct rspamd_task *task, GList * args, void *unused)
 {
        struct expression_argument     *arg;
 
@@ -941,7 +941,7 @@ rspamd_compare_encoding (struct worker_task *task, GList * args, void *unused)
 }
 
 gboolean
-rspamd_header_exists (struct worker_task * task, GList * args, void *unused)
+rspamd_header_exists (struct rspamd_task * task, GList * args, void *unused)
 {
        struct expression_argument     *arg;
        GList                          *headerlist;
@@ -972,7 +972,7 @@ rspamd_header_exists (struct worker_task * task, GList * args, void *unused)
  * and return FALSE otherwise.
  */
 gboolean
-rspamd_parts_distance (struct worker_task * task, GList * args, void *unused)
+rspamd_parts_distance (struct rspamd_task * task, GList * args, void *unused)
 {
        gint                            threshold, threshold2 = -1, diff;
        struct mime_text_part          *p1, *p2;
@@ -1103,7 +1103,7 @@ struct addr_list {
 #define MIN_RCPT_TO_COMPARE 7
 
 gboolean
-rspamd_recipients_distance (struct worker_task *task, GList * args, void *unused)
+rspamd_recipients_distance (struct rspamd_task *task, GList * args, void *unused)
 {
        struct expression_argument     *arg;
        InternetAddressList            *cur;
@@ -1188,7 +1188,7 @@ rspamd_recipients_distance (struct worker_task *task, GList * args, void *unused
 }
 
 gboolean
-rspamd_has_only_html_part (struct worker_task * task, GList * args, void *unused)
+rspamd_has_only_html_part (struct rspamd_task * task, GList * args, void *unused)
 {
        struct mime_text_part          *p;
        GList                          *cur;
@@ -1262,7 +1262,7 @@ is_recipient_list_sorted (const InternetAddressList * ia)
 }
 
 gboolean
-rspamd_is_recipients_sorted (struct worker_task * task, GList * args, void *unused)
+rspamd_is_recipients_sorted (struct rspamd_task * task, GList * args, void *unused)
 {
        /* Check all types of addresses */
        if (is_recipient_list_sorted (g_mime_message_get_recipients (task->message, GMIME_RECIPIENT_TYPE_TO)) == TRUE) {
@@ -1279,7 +1279,7 @@ rspamd_is_recipients_sorted (struct worker_task * task, GList * args, void *unus
 }
 
 gboolean
-rspamd_compare_transfer_encoding (struct worker_task * task, GList * args, void *unused)
+rspamd_compare_transfer_encoding (struct rspamd_task * task, GList * args, void *unused)
 {
        GMimeObject                    *part;
 #ifndef GMIME24
@@ -1340,7 +1340,7 @@ rspamd_compare_transfer_encoding (struct worker_task * task, GList * args, void
 }
 
 gboolean
-rspamd_is_html_balanced (struct worker_task * task, GList * args, void *unused)
+rspamd_is_html_balanced (struct rspamd_task * task, GList * args, void *unused)
 {
        struct mime_text_part          *p;
        GList                          *cur;
@@ -1388,7 +1388,7 @@ search_html_node_callback (GNode * node, gpointer data)
 }
 
 gboolean
-rspamd_has_html_tag (struct worker_task * task, GList * args, void *unused)
+rspamd_has_html_tag (struct rspamd_task * task, GList * args, void *unused)
 {
        struct mime_text_part          *p;
        GList                          *cur;
@@ -1426,7 +1426,7 @@ rspamd_has_html_tag (struct worker_task * task, GList * args, void *unused)
 }
 
 gboolean
-rspamd_has_fake_html (struct worker_task * task, GList * args, void *unused)
+rspamd_has_fake_html (struct rspamd_task * task, GList * args, void *unused)
 {
        struct mime_text_part          *p;
        GList                          *cur;
index 526af86866e519243fb727371fe8fda2f1c391b8..954cc74f7442eaae6166398b7a6eac9eaad864ee 100644 (file)
@@ -9,7 +9,7 @@
 #include "config.h"
 #include <lua.h>
 
-struct worker_task;
+struct rspamd_task;
 struct rspamd_regexp;
 
 /**
@@ -51,7 +51,7 @@ struct expression {
        struct expression *next;                                                                        /**< chain link                                                                         */
 };
 
-typedef gboolean (*rspamd_internal_func_t)(struct worker_task *, GList *args, void *user_data);
+typedef gboolean (*rspamd_internal_func_t)(struct rspamd_task *, GList *args, void *user_data);
 
 /**
  * Parse regexp line to regexp structure
@@ -76,7 +76,7 @@ struct expression* parse_expression (rspamd_mempool_t *pool, gchar *line);
  * @param L lua specific state
  * @return TRUE or FALSE depending on function result
  */
-gboolean call_expression_function (struct expression_function *func, struct worker_task *task, lua_State *L);
+gboolean call_expression_function (struct expression_function *func, struct rspamd_task *task, lua_State *L);
 
 /**
  * Register specified function to rspamd internal functions list
@@ -111,7 +111,7 @@ void re_cache_del (const gchar *line, rspamd_mempool_t *pool);
  * @param pointer regexp data
  * @param result numeric result of this regexp
  */
-void task_cache_add (struct worker_task *task, struct rspamd_regexp *re, gint32 result);
+void task_cache_add (struct rspamd_task *task, struct rspamd_regexp *re, gint32 result);
 
 /**
  * Check regexp in cache
@@ -119,7 +119,7 @@ void task_cache_add (struct worker_task *task, struct rspamd_regexp *re, gint32
  * @param pointer regexp data
  * @return numeric result if value exists or -1 if not
  */
-gint32 task_cache_check (struct worker_task *task, struct rspamd_regexp *re);
+gint32 task_cache_check (struct rspamd_task *task, struct rspamd_regexp *re);
 
 /**
  * Parse and return a single function argument for a function (may recurse)
@@ -128,6 +128,6 @@ gint32 task_cache_check (struct worker_task *task, struct rspamd_regexp *re);
  * @param want_string return NULL if argument is not a string
  * @return expression argument structure or NULL if failed
  */
-struct expression_argument *get_function_arg (struct expression *expr, struct worker_task *task, gboolean want_string);
+struct expression_argument *get_function_arg (struct expression *expr, struct rspamd_task *task, gboolean want_string);
 
 #endif
index d5e430e382b145353b3e61ac24032be5e69422d2..f0da620ad37c8efe93dfe5ffa535fae5fc90f80f 100644 (file)
@@ -63,7 +63,7 @@ filter_error_quark (void)
 }
 
 static void
-insert_metric_result (struct worker_task *task, struct metric *metric, const gchar *symbol,
+insert_metric_result (struct rspamd_task *task, struct metric *metric, const gchar *symbol,
                double flag, GList * opts, gboolean single)
 {
        struct metric_result           *metric_res;
@@ -164,7 +164,7 @@ G_LOCK_DEFINE (result_mtx);
 #endif
 
 static void
-insert_result_common (struct worker_task *task, const gchar *symbol, double flag, GList * opts, gboolean single)
+insert_result_common (struct rspamd_task *task, const gchar *symbol, double flag, GList * opts, gboolean single)
 {
        struct metric                  *metric;
        struct cache_item              *item;
@@ -212,21 +212,21 @@ insert_result_common (struct worker_task *task, const gchar *symbol, double flag
 
 /* Insert result that may be increased on next insertions */
 void
-insert_result (struct worker_task *task, const gchar *symbol, double flag, GList * opts)
+insert_result (struct rspamd_task *task, const gchar *symbol, double flag, GList * opts)
 {
        insert_result_common (task, symbol, flag, opts, task->cfg->one_shot_mode);
 }
 
 /* Insert result as a single option */
 void
-insert_result_single (struct worker_task *task, const gchar *symbol, double flag, GList * opts)
+insert_result_single (struct rspamd_task *task, const gchar *symbol, double flag, GList * opts)
 {
        insert_result_common (task, symbol, flag, opts, TRUE);
 }
 
 /* Return true if metric has score that is more than spam score for it */
 static                          gboolean
-check_metric_is_spam (struct worker_task *task, struct metric *metric)
+check_metric_is_spam (struct rspamd_task *task, struct metric *metric)
 {
        struct metric_result           *res;
        double                          ms, rs;
@@ -260,7 +260,7 @@ check_metric_is_spam (struct worker_task *task, struct metric *metric)
 }
 
 gint
-process_filters (struct worker_task *task)
+process_filters (struct rspamd_task *task)
 {
        GList                          *cur;
        struct metric                  *metric;
@@ -297,7 +297,7 @@ process_filters (struct worker_task *task)
 
 
 struct composites_data {
-       struct worker_task             *task;
+       struct rspamd_task             *task;
        struct metric_result           *metric_res;
        GTree                          *symbols_to_remove;
        guint8                                             *checked;
@@ -470,7 +470,7 @@ composites_foreach_callback (gpointer key, gpointer value, void *data)
 }
 
 static                          gboolean
-check_autolearn (struct statfile_autolearn_params *params, struct worker_task *task)
+check_autolearn (struct statfile_autolearn_params *params, struct rspamd_task *task)
 {
        gchar                          *metric_name = DEFAULT_METRIC;
        struct metric_result           *metric_res;
@@ -512,7 +512,7 @@ check_autolearn (struct statfile_autolearn_params *params, struct worker_task *t
 }
 
 void
-process_autolearn (struct statfile *st, struct worker_task *task, GTree * tokens, struct classifier *classifier, gchar *filename, struct classifier_ctx *ctx)
+process_autolearn (struct statfile *st, struct rspamd_task *task, GTree * tokens, struct classifier *classifier, gchar *filename, struct classifier_ctx *ctx)
 {
        stat_file_t                    *statfile;
        struct statfile                *unused;
@@ -557,7 +557,7 @@ composites_remove_symbols (gpointer key, gpointer value, gpointer data)
 static void
 composites_metric_callback (gpointer key, gpointer value, gpointer data)
 {
-       struct worker_task             *task = (struct worker_task *)data;
+       struct rspamd_task             *task = (struct rspamd_task *)data;
        struct composites_data         *cd = rspamd_mempool_alloc (task->task_pool, sizeof (struct composites_data));
        struct metric_result           *metric_res = (struct metric_result *)value;
 
@@ -576,13 +576,13 @@ composites_metric_callback (gpointer key, gpointer value, gpointer data)
 }
 
 void
-make_composites (struct worker_task *task)
+make_composites (struct rspamd_task *task)
 {
        g_hash_table_foreach (task->results, composites_metric_callback, task);
 }
 
 struct classifiers_cbdata {
-       struct worker_task *task;
+       struct rspamd_task *task;
        struct lua_locked_state *nL;
 };
 
@@ -590,7 +590,7 @@ static void
 classifiers_callback (gpointer value, void *arg)
 {
        struct classifiers_cbdata          *cbdata = arg;
-       struct worker_task             *task;
+       struct rspamd_task             *task;
        struct classifier_config       *cl = value;
        struct classifier_ctx          *ctx;
        struct mime_text_part          *text_part, *p1, *p2;
@@ -706,7 +706,7 @@ classifiers_callback (gpointer value, void *arg)
 
 
 void
-process_statfiles (struct worker_task *task)
+process_statfiles (struct rspamd_task *task)
 {
        struct classifiers_cbdata               cbdata;
 
@@ -729,7 +729,7 @@ process_statfiles (struct worker_task *task)
 void
 process_statfiles_threaded (gpointer data, gpointer user_data)
 {
-       struct worker_task             *task = (struct worker_task *)data;
+       struct rspamd_task             *task = (struct rspamd_task *)data;
        struct lua_locked_state            *nL = user_data;
        struct classifiers_cbdata               cbdata;
 
@@ -753,7 +753,7 @@ static void
 insert_metric_header (gpointer metric_name, gpointer metric_value, gpointer data)
 {
 #ifndef GLIB_HASH_COMPAT
-       struct worker_task             *task = (struct worker_task *)data;
+       struct rspamd_task             *task = (struct rspamd_task *)data;
        gint                            r = 0;
        /* Try to be rfc2822 compatible and avoid long headers with folding */
        gchar                           header_name[128], outbuf[1000];
@@ -795,7 +795,7 @@ insert_metric_header (gpointer metric_name, gpointer metric_value, gpointer data
 }
 
 void
-insert_headers (struct worker_task *task)
+insert_headers (struct rspamd_task *task)
 {
        g_hash_table_foreach (task->results, insert_metric_header, task);
 }
@@ -878,7 +878,7 @@ check_metric_action (double score, double required_score, struct metric *metric)
 }
 
 gboolean
-learn_task (const gchar *statfile, struct worker_task *task, GError **err)
+learn_task (const gchar *statfile, struct rspamd_task *task, GError **err)
 {
        GList                          *cur, *ex;
        struct classifier_config       *cl;
@@ -1006,7 +1006,7 @@ learn_task (const gchar *statfile, struct worker_task *task, GError **err)
 }
 
 gboolean
-learn_task_spam (struct classifier_config *cl, struct worker_task *task, gboolean is_spam, GError **err)
+learn_task_spam (struct classifier_config *cl, struct rspamd_task *task, gboolean is_spam, GError **err)
 {
        GList                          *cur, *ex;
        struct classifier_ctx          *cls_ctx;
index 79fae64495005e737adb1c3bafd1419603fe3e4a..b06dbeef12421bdf31a7820f4e655c90ce40c5cb 100644 (file)
@@ -9,12 +9,12 @@
 #include "config.h"
 #include "symbols_cache.h"
 
-struct worker_task;
+struct rspamd_task;
 struct rspamd_settings;
 struct classifier_config;
 
-typedef double (*metric_cons_func)(struct worker_task *task, const gchar *metric_name, const gchar *func_name);
-typedef void (*filter_func)(struct worker_task *task);
+typedef double (*metric_cons_func)(struct rspamd_task *task, const gchar *metric_name, const gchar *func_name);
+typedef void (*filter_func)(struct rspamd_task *task);
 
 enum filter_type { C_FILTER, PERL_FILTER };
 
@@ -36,16 +36,6 @@ struct symbol {
        const gchar *name;
 };
 
-enum rspamd_metric_action {
-       METRIC_ACTION_REJECT = 0,
-       METRIC_ACTION_SOFT_REJECT,
-       METRIC_ACTION_REWRITE_SUBJECT,
-       METRIC_ACTION_ADD_HEADER,
-       METRIC_ACTION_GREYLIST,
-       METRIC_ACTION_NOACTION,
-       METRIC_ACTION_MAX
-};
-
 struct metric_action {
        enum rspamd_metric_action action;
        gdouble score;
@@ -91,13 +81,13 @@ struct rspamd_composite {
  * @param task worker's task that present message from user
  * @return 0 - if there is non-finished tasks and 1 if processing is completed
  */
-gint process_filters (struct worker_task *task);
+gint process_filters (struct rspamd_task *task);
 
 /**
  * Process message with statfiles
  * @param task worker's task that present message from user
  */
-void process_statfiles (struct worker_task *task);
+void process_statfiles (struct rspamd_task *task);
 
 /**
  * Process message with statfiles threaded
@@ -113,7 +103,7 @@ void process_statfiles_threaded (gpointer data, gpointer user_data);
  * @param flag numeric weight for symbol
  * @param opts list of symbol's options
  */
-void insert_result (struct worker_task *task, const gchar *symbol, double flag, GList *opts);
+void insert_result (struct rspamd_task *task, const gchar *symbol, double flag, GList *opts);
 
 /**
  * Insert a single result to task
@@ -123,13 +113,13 @@ void insert_result (struct worker_task *task, const gchar *symbol, double flag,
  * @param flag numeric weight for symbol
  * @param opts list of symbol's options
  */
-void insert_result_single (struct worker_task *task, const gchar *symbol, double flag, GList *opts);
+void insert_result_single (struct rspamd_task *task, const gchar *symbol, double flag, GList *opts);
 
 /**
  * Process all results and form composite metrics from existent metrics as it is defined in config
  * @param task worker's task that present message from user
  */
-void make_composites (struct worker_task *task);
+void make_composites (struct rspamd_task *task);
 
 /**
  * Default consolidation function for metric, it get all symbols and multiply symbol 
@@ -138,7 +128,7 @@ void make_composites (struct worker_task *task);
  * @param metric_name name of metric
  * @return result metric weight
  */
-double factor_consolidation_func (struct worker_task *task, const gchar *metric_name, const gchar *unused);
+double factor_consolidation_func (struct rspamd_task *task, const gchar *metric_name, const gchar *unused);
 
 /*
  * Learn specified statfile with message in a task
@@ -147,7 +137,7 @@ double factor_consolidation_func (struct worker_task *task, const gchar *metric_
  * @param err pointer to GError
  * @return true if learn succeed
  */
-gboolean learn_task (const gchar *statfile, struct worker_task *task, GError **err);
+gboolean learn_task (const gchar *statfile, struct rspamd_task *task, GError **err);
 
 /*
  * Learn specified statfile with message in a task
@@ -156,7 +146,7 @@ gboolean learn_task (const gchar *statfile, struct worker_task *task, GError **e
  * @param err pointer to GError
  * @return true if learn succeed
  */
-gboolean learn_task_spam (struct classifier_config *cl, struct worker_task *task, gboolean is_spam, GError **err);
+gboolean learn_task_spam (struct classifier_config *cl, struct rspamd_task *task, gboolean is_spam, GError **err);
 
 /*
  * Get action from a string
index 1f6d091d35394649a358ef5fe8c2272d78cc859b..028c54f6cbff4f3f2d2d7cdbaacf4395b31fe0e9 100644 (file)
@@ -656,7 +656,7 @@ decode_entitles (gchar *s, guint * len)
 }
 
 static void
-check_phishing (struct worker_task *task, struct uri *href_url, const gchar *url_text, gsize remain, tag_id_t id)
+check_phishing (struct rspamd_task *task, struct uri *href_url, const gchar *url_text, gsize remain, tag_id_t id)
 {
        struct uri                     *new;
        gchar                          *url_str;
@@ -770,7 +770,7 @@ check_phishing (struct worker_task *task, struct uri *href_url, const gchar *url
 }
 
 static void
-parse_tag_url (struct worker_task *task, struct mime_text_part *part, tag_id_t id,
+parse_tag_url (struct rspamd_task *task, struct mime_text_part *part, tag_id_t id,
                gchar *tag_text, gsize tag_len, gsize remain)
 {
        gchar                           *c = NULL, *p, *url_text;
@@ -869,7 +869,7 @@ parse_tag_url (struct worker_task *task, struct mime_text_part *part, tag_id_t i
 }
 
 gboolean
-add_html_node (struct worker_task *task, rspamd_mempool_t * pool, struct mime_text_part *part,
+add_html_node (struct rspamd_task *task, rspamd_mempool_t * pool, struct mime_text_part *part,
                gchar *tag_text, gsize tag_len, gsize remain, GNode ** cur_level)
 {
        GNode                          *new;
index 601f076d22624d125f73b754cc089bf9b8c4b95c..3ea758e600ef27ed517b647e11cdaec3d045b404 100644 (file)
@@ -205,12 +205,12 @@ struct html_node {
 };
 
 /* Forwarded declaration */
-struct worker_task;
+struct rspamd_task;
 
 /*
  * Add a single node to the tags tree
  */
-gboolean add_html_node (struct worker_task *task, rspamd_mempool_t *pool,
+gboolean add_html_node (struct rspamd_task *task, rspamd_mempool_t *pool,
                struct mime_text_part *part, gchar *tag_text, gsize tag_len, gsize remain, GNode **cur_level);
 
 /*
index e3b30016684dc56bc693a43ad85321f2876c3d4c..ff07bbd7255d2c4d904af5022f8b7b502189829d 100644 (file)
@@ -32,11 +32,11 @@ static const guint8 jpg_sig2[] = {'J', 'F', 'I', 'F'};
 static const guint8 gif_signature[] = {'G', 'I', 'F', '8'};
 static const guint8 bmp_signature[] = {'B', 'M'};
 
-static void                     process_image (struct worker_task *task, struct mime_part *part);
+static void                     process_image (struct rspamd_task *task, struct mime_part *part);
 
 
 void
-process_images (struct worker_task *task)
+process_images (struct rspamd_task *task)
 {
        GList                          *cur;
        struct mime_part                           *part;
@@ -83,7 +83,7 @@ detect_image_type (GByteArray *data)
 
 
 static struct rspamd_image *
-process_png_image (struct worker_task *task, GByteArray *data)
+process_png_image (struct rspamd_task *task, GByteArray *data)
 {
        struct rspamd_image             *img;
        guint32                          t;
@@ -117,7 +117,7 @@ process_png_image (struct worker_task *task, GByteArray *data)
 }
 
 static struct rspamd_image *
-process_jpg_image (struct worker_task *task, GByteArray *data)
+process_jpg_image (struct rspamd_task *task, GByteArray *data)
 {
        guint8                          *p;
        guint16                          t;
@@ -146,7 +146,7 @@ process_jpg_image (struct worker_task *task, GByteArray *data)
 }
 
 static struct rspamd_image *
-process_gif_image (struct worker_task *task, GByteArray *data)
+process_gif_image (struct rspamd_task *task, GByteArray *data)
 {
        struct rspamd_image             *img;
        guint8                          *p;
@@ -171,7 +171,7 @@ process_gif_image (struct worker_task *task, GByteArray *data)
 }
 
 static struct rspamd_image *
-process_bmp_image (struct worker_task *task, GByteArray *data)
+process_bmp_image (struct rspamd_task *task, GByteArray *data)
 {
        struct rspamd_image             *img;
        gint32                           t;
@@ -197,7 +197,7 @@ process_bmp_image (struct worker_task *task, GByteArray *data)
 }
 
 static void
-process_image (struct worker_task *task, struct mime_part *part)
+process_image (struct rspamd_task *task, struct mime_part *part)
 {
        enum known_image_types          type;
        struct rspamd_image            *img = NULL;
index 5561ecb7dd9d82f3bd80effb6941cd2c31cb63ab..c43941ebcefbe95a0dab4ff980a80c8f522e97ae 100644 (file)
@@ -23,7 +23,7 @@ struct rspamd_image {
 /*
  * Process images from a worker task
  */
-void process_images (struct worker_task *task);
+void process_images (struct rspamd_task *task);
 
 /*
  * Get textual representation of an image's type
index 8ffef771f350c9995f1842e04bda6558a7daf504..c79c46376c0f9c2c834d52e13f5baaff1046f58d 100644 (file)
@@ -103,7 +103,7 @@ sigusr1_handler (gint fd, short what, void *arg)
 static void
 rcpt_destruct (void *pointer)
 {
-       struct worker_task             *task = (struct worker_task *)pointer;
+       struct rspamd_task             *task = (struct rspamd_task *)pointer;
 
        if (task->rcpt) {
                g_list_free (task->rcpt);
@@ -118,7 +118,7 @@ free_lmtp_task (struct rspamd_lmtp_proto *lmtp, gboolean is_soft)
 {
        GList                          *part;
        struct mime_part               *p;
-       struct worker_task             *task = lmtp->task;
+       struct rspamd_task             *task = lmtp->task;
 
        if (lmtp) {
                debug_task ("free pointer %p", lmtp->task);
@@ -149,7 +149,7 @@ static                          gboolean
 lmtp_read_socket (f_str_t * in, void *arg)
 {
        struct rspamd_lmtp_proto       *lmtp = (struct rspamd_lmtp_proto *)arg;
-       struct worker_task             *task = lmtp->task;
+       struct rspamd_task             *task = lmtp->task;
        ssize_t                         r;
 
        switch (task->state) {
@@ -195,7 +195,7 @@ static                          gboolean
 lmtp_write_socket (void *arg)
 {
        struct rspamd_lmtp_proto       *lmtp = (struct rspamd_lmtp_proto *)arg;
-       struct worker_task             *task = lmtp->task;
+       struct rspamd_task             *task = lmtp->task;
 
        switch (lmtp->task->state) {
        case WRITE_REPLY:
@@ -243,7 +243,7 @@ accept_socket (gint fd, short what, void *arg)
 {
        struct rspamd_worker           *worker = (struct rspamd_worker *)arg;
        union sa_union                  su;
-       struct worker_task             *new_task;
+       struct rspamd_task             *new_task;
        struct rspamd_lmtp_proto       *lmtp;
        socklen_t                       addrlen = sizeof (su.ss);
        gint                            nfd;
index 06edc06ade69beaa61a1a0b3025c3aa7ee892918..81cd13607eb92c194ee755d5599a5acd14d0e2ce 100644 (file)
@@ -89,7 +89,7 @@ extract_mail (rspamd_mempool_t * pool, f_str_t * line)
 }
 
 static gboolean
-out_lmtp_reply (struct worker_task *task, gint code, gchar *rcode, gchar *msg)
+out_lmtp_reply (struct rspamd_task *task, gint code, gchar *rcode, gchar *msg)
 {
        gchar                           outbuf[OUTBUFSIZ];
        gint                            r;
@@ -252,7 +252,7 @@ read_lmtp_input_line (struct rspamd_lmtp_proto *lmtp, f_str_t * line)
 }
 
 struct mta_callback_data {
-       struct worker_task             *task;
+       struct rspamd_task             *task;
        rspamd_io_dispatcher_t         *dispatcher;
        enum {
                LMTP_WANT_GREETING,
@@ -445,7 +445,7 @@ mta_err_socket (GError * err, void *arg)
  * Deliver mail via smtp or lmtp
  */
 static gint
-lmtp_deliver_mta (struct worker_task *task)
+lmtp_deliver_mta (struct rspamd_task *task)
 {
        gint                            sock;
        struct sockaddr_un             *un;
@@ -471,7 +471,7 @@ lmtp_deliver_mta (struct worker_task *task)
 }
 
 static gchar                    *
-format_lda_args (struct worker_task *task)
+format_lda_args (struct rspamd_task *task)
 {
        gchar                           *res, *c, *r;
        size_t                          len;
@@ -555,7 +555,7 @@ format_lda_args (struct worker_task *task)
 }
 
 static gint
-lmtp_deliver_lda (struct worker_task *task)
+lmtp_deliver_lda (struct rspamd_task *task)
 {
        gchar                           *args, **argv;
        GMimeStream                    *stream;
@@ -652,7 +652,7 @@ lmtp_deliver_lda (struct worker_task *task)
 }
 
 gint
-lmtp_deliver_message (struct worker_task *task)
+lmtp_deliver_message (struct rspamd_task *task)
 {
        if (task->cfg->deliver_agent_path != NULL) {
                /* Do deliver to LDA */
@@ -668,7 +668,7 @@ gint
 write_lmtp_reply (struct rspamd_lmtp_proto *lmtp)
 {
        gint                            r;
-       struct worker_task             *task = lmtp->task;
+       struct rspamd_task             *task = lmtp->task;
 
        debug_task ("writing reply to client");
        if (lmtp->task->error_code != 0) {
index 11d994e698de442debcdcfcfabc171c24d863df5..1439158182c1bee2f8b6003133857f4673ee6bdc 100644 (file)
@@ -3,7 +3,7 @@
 
 #include "config.h"
 
-struct worker_task;
+struct rspamd_task;
 
 enum lmtp_state {
        LMTP_READ_LHLO,
@@ -15,7 +15,7 @@ enum lmtp_state {
 };
 
 struct rspamd_lmtp_proto {
-       struct worker_task *task;
+       struct rspamd_task *task;
        enum lmtp_state state;
 };
 
@@ -32,7 +32,7 @@ gint read_lmtp_input_line (struct rspamd_lmtp_proto *lmtp, f_str_t *line);
  * @param task task object
  * @return 0 if we wrote message and -1 if there was some error
  */
-gint lmtp_deliver_message (struct worker_task *task);
+gint lmtp_deliver_message (struct rspamd_task *task);
 
 /**
  * Write reply for specified lmtp object
index cc9c713093fd4428f01591bd5732639f0588140c..8325db1072a64ccd8a6d57fb7e44032701a4f36e 100644 (file)
@@ -193,7 +193,7 @@ lua_post_load_config (struct config_file *cfg)
 
 /* Handle lua dynamic config param */
 gboolean
-lua_handle_param (struct worker_task *task, gchar *mname, gchar *optname, enum lua_var_type expected_type, gpointer *res)
+lua_handle_param (struct rspamd_task *task, gchar *mname, gchar *optname, enum lua_var_type expected_type, gpointer *res)
 {
        /* xxx: Adopt this for rcl */
        
index 82e7ea2b7c0036118d3f25cf9dbec8e5b81e4b09..1e33f704d180a9a89905a6f9f913b31994afe6e0 100644 (file)
@@ -80,11 +80,11 @@ lua_check_classifier (lua_State * L)
 }
 
 static GList *
-call_classifier_pre_callback (struct classifier_config *ccf, struct worker_task *task,
+call_classifier_pre_callback (struct classifier_config *ccf, struct rspamd_task *task,
                lua_State *L, gboolean is_learn, gboolean is_spam)
 {
        struct classifier_config      **pccf;
-       struct worker_task            **ptask;
+       struct rspamd_task            **ptask;
        struct statfile               **pst;
        GList                          *res = NULL;
 
@@ -92,7 +92,7 @@ call_classifier_pre_callback (struct classifier_config *ccf, struct worker_task
        lua_setclass (L, "rspamd{classifier}", -1);
        *pccf = ccf;
 
-       ptask = lua_newuserdata (L, sizeof (struct worker_task *));
+       ptask = lua_newuserdata (L, sizeof (struct rspamd_task *));
        lua_setclass (L, "rspamd{task}", -1);
        *ptask = task;
 
@@ -120,7 +120,7 @@ call_classifier_pre_callback (struct classifier_config *ccf, struct worker_task
 
 /* Return list of statfiles that should be checked for this message */
 GList *
-call_classifier_pre_callbacks (struct classifier_config *ccf, struct worker_task *task,
+call_classifier_pre_callbacks (struct classifier_config *ccf, struct rspamd_task *task,
                gboolean is_learn, gboolean is_spam, lua_State *L)
 {
        GList                           *res = NULL, *cur;
@@ -158,11 +158,11 @@ call_classifier_pre_callbacks (struct classifier_config *ccf, struct worker_task
 
 /* Return result mark for statfile */
 double
-call_classifier_post_callbacks (struct classifier_config *ccf, struct worker_task *task, double in, lua_State *L)
+call_classifier_post_callbacks (struct classifier_config *ccf, struct rspamd_task *task, double in, lua_State *L)
 {
        struct classifier_callback_data *cd;
        struct classifier_config      **pccf;
-       struct worker_task            **ptask;
+       struct rspamd_task            **ptask;
        double                          out = in;
        GList                          *cur;
 
@@ -176,7 +176,7 @@ call_classifier_post_callbacks (struct classifier_config *ccf, struct worker_tas
                lua_setclass (L, "rspamd{classifier}", -1);
                *pccf = ccf;
 
-               ptask = lua_newuserdata (L, sizeof (struct worker_task *));
+               ptask = lua_newuserdata (L, sizeof (struct rspamd_task *));
                lua_setclass (L, "rspamd{task}", -1);
                *ptask = task;
 
index 0774615e5ee5c7d1cba3aeb8b938e6e8abf18b5c..ee624db3d2d0ef6273fd8f23240a7ab4826724c8 100644 (file)
@@ -400,14 +400,14 @@ init_lua_filters (struct config_file *cfg)
 /* Callback functions */
 
 gint
-lua_call_filter (const gchar *function, struct worker_task *task)
+lua_call_filter (const gchar *function, struct rspamd_task *task)
 {
        gint                            result;
-       struct worker_task            **ptask;
+       struct rspamd_task            **ptask;
        lua_State                      *L = task->cfg->lua_state;
 
        lua_getglobal (L, function);
-       ptask = lua_newuserdata (L, sizeof (struct worker_task *));
+       ptask = lua_newuserdata (L, sizeof (struct rspamd_task *));
        lua_setclass (L, "rspamd{task}", -1);
        *ptask = task;
 
@@ -426,7 +426,7 @@ lua_call_filter (const gchar *function, struct worker_task *task)
 }
 
 gint
-lua_call_chain_filter (const gchar *function, struct worker_task *task, gint *marks, guint number)
+lua_call_chain_filter (const gchar *function, struct rspamd_task *task, gint *marks, guint number)
 {
        gint                            result;
        guint                           i;
@@ -454,17 +454,17 @@ lua_call_chain_filter (const gchar *function, struct worker_task *task, gint *ma
 /* Call custom lua function in rspamd expression */
 gboolean 
 lua_call_expression_func (gpointer lua_data,
-               struct worker_task *task, GList *args, gboolean *res)
+               struct rspamd_task *task, GList *args, gboolean *res)
 {
        lua_State                      *L = task->cfg->lua_state;
-       struct worker_task            **ptask;
+       struct rspamd_task            **ptask;
        GList                          *cur;
        struct expression_argument     *arg;
        int                             nargs = 1, pop = 0;
 
        lua_rawgeti (L, LUA_REGISTRYINDEX, GPOINTER_TO_INT (lua_data));
        /* Now we got function in top of stack */
-       ptask = lua_newuserdata (L, sizeof (struct worker_task *));
+       ptask = lua_newuserdata (L, sizeof (struct rspamd_task *));
        lua_setclass (L, "rspamd{task}", -1);
        *ptask = task;
        
@@ -511,7 +511,7 @@ lua_call_expression_func (gpointer lua_data,
  * LUA custom consolidation function
  */
 struct consolidation_callback_data {
-       struct worker_task             *task;
+       struct rspamd_task             *task;
        double                          score;
        const gchar                     *func;
 };
@@ -542,7 +542,7 @@ lua_consolidation_callback (gpointer key, gpointer value, gpointer arg)
 }
 
 double
-lua_consolidation_func (struct worker_task *task, const gchar *metric_name, const gchar *function_name)
+lua_consolidation_func (struct rspamd_task *task, const gchar *metric_name, const gchar *function_name)
 {
        struct metric_result           *metric_res;
        double                          res = 0.;
index d03ca168e42508a77071760f7913421125f60673..9902fd845903af589156b7a3ce315367b7ac9c8b 100644 (file)
@@ -179,17 +179,17 @@ gint luaopen_dns_resolver (lua_State * L);
 gint luaopen_rsa (lua_State * L);
 gint luaopen_ip (lua_State * L);
 
-gint lua_call_filter (const gchar *function, struct worker_task *task);
-gint lua_call_chain_filter (const gchar *function, struct worker_task *task, gint *marks, guint number);
-double lua_consolidation_func (struct worker_task *task, const gchar *metric_name, const gchar *function_name);
-gboolean lua_call_expression_func (gpointer lua_data, struct worker_task *task, GList *args, gboolean *res);
-void lua_call_post_filters (struct worker_task *task);
-void lua_call_pre_filters (struct worker_task *task);
+gint lua_call_filter (const gchar *function, struct rspamd_task *task);
+gint lua_call_chain_filter (const gchar *function, struct rspamd_task *task, gint *marks, guint number);
+double lua_consolidation_func (struct rspamd_task *task, const gchar *metric_name, const gchar *function_name);
+gboolean lua_call_expression_func (gpointer lua_data, struct rspamd_task *task, GList *args, gboolean *res);
+void lua_call_post_filters (struct rspamd_task *task);
+void lua_call_pre_filters (struct rspamd_task *task);
 void add_luabuf (const gchar *line);
 
 /* Classify functions */
-GList *call_classifier_pre_callbacks (struct classifier_config *ccf, struct worker_task *task, gboolean is_learn, gboolean is_spam, lua_State *L);
-double call_classifier_post_callbacks (struct classifier_config *ccf, struct worker_task *task, double in, lua_State *L);
+GList *call_classifier_pre_callbacks (struct classifier_config *ccf, struct rspamd_task *task, gboolean is_learn, gboolean is_spam, lua_State *L);
+double call_classifier_post_callbacks (struct classifier_config *ccf, struct rspamd_task *task, double in, lua_State *L);
 
 double lua_normalizer_func (struct config_file *cfg, long double score, void *params);
 
@@ -197,7 +197,7 @@ double lua_normalizer_func (struct config_file *cfg, long double score, void *pa
 void lua_post_load_config (struct config_file *cfg);
 void lua_process_element (struct config_file *cfg, const gchar *name,
                const gchar *module_name, struct module_opt *opt, gint idx, gboolean allow_meta);
-gboolean lua_handle_param (struct worker_task *task, gchar *mname, gchar *optname, 
+gboolean lua_handle_param (struct rspamd_task *task, gchar *mname, gchar *optname, 
                                                        enum lua_var_type expected_type, gpointer *res);
 gboolean lua_check_condition (struct config_file *cfg, const gchar *condition);
 void lua_dumpstack (lua_State *L);
index b8be57896faf6aeee458c55ba640dc246e508c85..d922cac471b387b21c6124bbe735331daf1ff81c 100644 (file)
@@ -266,10 +266,10 @@ lua_destroy_cfg_symbol (gpointer ud)
 }
 
 static gboolean
-lua_config_function_callback (struct worker_task *task, GList *args, void *user_data)
+lua_config_function_callback (struct rspamd_task *task, GList *args, void *user_data)
 {
        struct lua_callback_data       *cd = user_data;
-       struct worker_task            **ptask;
+       struct rspamd_task            **ptask;
        gint                            i = 1;
        struct expression_argument     *arg;
        GList                          *cur;
@@ -281,7 +281,7 @@ lua_config_function_callback (struct worker_task *task, GList *args, void *user_
        else {
                lua_getglobal (cd->L, cd->callback.name);
        }
-       ptask = lua_newuserdata (cd->L, sizeof (struct worker_task *));
+       ptask = lua_newuserdata (cd->L, sizeof (struct rspamd_task *));
        lua_setclass (cd->L, "rspamd{task}", -1);
        *ptask = task;
        /* Now push all arguments */
@@ -346,10 +346,10 @@ lua_config_register_module_option (lua_State *L)
 }
 
 void
-lua_call_post_filters (struct worker_task *task)
+lua_call_post_filters (struct rspamd_task *task)
 {
        struct lua_callback_data       *cd;
-       struct worker_task            **ptask;
+       struct rspamd_task            **ptask;
        GList                          *cur;
 
        cur = task->cfg->post_filters;
@@ -361,7 +361,7 @@ lua_call_post_filters (struct worker_task *task)
                else {
                        lua_getglobal (cd->L, cd->callback.name);
                }
-               ptask = lua_newuserdata (cd->L, sizeof (struct worker_task *));
+               ptask = lua_newuserdata (cd->L, sizeof (struct rspamd_task *));
                lua_setclass (cd->L, "rspamd{task}", -1);
                *ptask = task;
 
@@ -399,10 +399,10 @@ lua_config_register_post_filter (lua_State *L)
 }
 
 void
-lua_call_pre_filters (struct worker_task *task)
+lua_call_pre_filters (struct rspamd_task *task)
 {
        struct lua_callback_data       *cd;
-       struct worker_task            **ptask;
+       struct rspamd_task            **ptask;
        GList                          *cur;
 
        cur = task->cfg->pre_filters;
@@ -414,7 +414,7 @@ lua_call_pre_filters (struct worker_task *task)
                else {
                        lua_getglobal (cd->L, cd->callback.name);
                }
-               ptask = lua_newuserdata (cd->L, sizeof (struct worker_task *));
+               ptask = lua_newuserdata (cd->L, sizeof (struct rspamd_task *));
                lua_setclass (cd->L, "rspamd{task}", -1);
                *ptask = task;
 
@@ -547,10 +547,10 @@ lua_config_add_kv_map (lua_State *L)
 
 
 static void
-lua_metric_symbol_callback (struct worker_task *task, gpointer ud)
+lua_metric_symbol_callback (struct rspamd_task *task, gpointer ud)
 {
        struct lua_callback_data       *cd = ud;
-       struct worker_task            **ptask;
+       struct rspamd_task            **ptask;
 
        if (cd->cb_is_ref) {
                lua_rawgeti (cd->L, LUA_REGISTRYINDEX, cd->callback.ref);
@@ -558,7 +558,7 @@ lua_metric_symbol_callback (struct worker_task *task, gpointer ud)
        else {
                lua_getglobal (cd->L, cd->callback.name);
        }
-       ptask = lua_newuserdata (cd->L, sizeof (struct worker_task *));
+       ptask = lua_newuserdata (cd->L, sizeof (struct rspamd_task *));
        lua_setclass (cd->L, "rspamd{task}", -1);
        *ptask = task;
 
@@ -851,7 +851,7 @@ static gint
 lua_trie_search_task (lua_State *L)
 {
        rspamd_trie_t                 *trie = lua_check_trie (L);
-       struct worker_task            *task;
+       struct rspamd_task            *task;
        struct mime_text_part         *part;
        GList                         *cur;
        const gchar                   *pos, *end;
@@ -862,7 +862,7 @@ lua_trie_search_task (lua_State *L)
        if (trie) {
                ud = luaL_checkudata (L, 2, "rspamd{task}");
                luaL_argcheck (L, ud != NULL, 1, "'task' expected");
-               task = ud ? *((struct worker_task **)ud) : NULL;
+               task = ud ? *((struct rspamd_task **)ud) : NULL;
                if (task) {
                        lua_newtable (L);
                        cur = task->text_parts;
index 31bcffb779e552ef01f41d019511e6bcda8e7c5f..60253c0004dcf3bd26e3613610a7e922a2197b9d 100644 (file)
@@ -44,7 +44,7 @@ struct lua_http_header {
 };
 
 struct lua_http_ud {
-       struct worker_task *task;
+       struct rspamd_task *task;
        gint parser_state;
        struct rspamd_async_session *s;
        rspamd_mempool_t *pool;
@@ -81,13 +81,13 @@ lua_http_fin (void *arg)
 static void
 lua_http_push_error (gint code, struct lua_http_ud *ud)
 {
-       struct worker_task            **ptask;
+       struct rspamd_task            **ptask;
        gint                                                    num;
 
        /* Push error */
        if (ud->callback) {
                lua_getglobal (ud->L, ud->callback);
-               ptask = lua_newuserdata (ud->L, sizeof (struct worker_task *));
+               ptask = lua_newuserdata (ud->L, sizeof (struct rspamd_task *));
                lua_setclass (ud->L, "rspamd{task}", -1);
                *ptask = ud->task;
                num = 4;
@@ -122,13 +122,13 @@ lua_http_push_reply (f_str_t *in, struct lua_http_ud *ud)
 {
        GList                          *cur;
        struct lua_http_header         *header;
-       struct worker_task            **ptask;
+       struct rspamd_task            **ptask;
        gint                                                    num;
 
        if (ud->callback) {
                /* Push error */
                lua_getglobal (ud->L, ud->callback);
-               ptask = lua_newuserdata (ud->L, sizeof (struct worker_task *));
+               ptask = lua_newuserdata (ud->L, sizeof (struct rspamd_task *));
                lua_setclass (ud->L, "rspamd{task}", -1);
 
                *ptask = ud->task;
@@ -339,7 +339,7 @@ lua_http_dns_callback (struct rdns_reply *reply, gpointer arg)
  * Common request function
  */
 static gint
-lua_http_make_request_common (lua_State *L, struct worker_task *task, const gchar *callback,
+lua_http_make_request_common (lua_State *L, struct rspamd_task *task, const gchar *callback,
                const gchar *hostname, const gchar *path, const gchar *data, gint top)
 {
        gint                           r, s, datalen;
@@ -518,7 +518,7 @@ lua_http_make_request_common_new (lua_State *L, struct rspamd_async_session *ses
 static gint
 lua_http_make_post_request (lua_State *L)
 {
-       struct worker_task            *task, **ptask;
+       struct rspamd_task            *task, **ptask;
        rspamd_mempool_t                                  *pool, **ppool;
        struct rspamd_async_session       *session, **psession;
        struct event_base                         *base, **pbase;
@@ -579,7 +579,7 @@ lua_http_make_post_request (lua_State *L)
 static gint
 lua_http_make_get_request (lua_State *L)
 {
-       struct worker_task            *task, **ptask;
+       struct rspamd_task            *task, **ptask;
        rspamd_mempool_t                                  *pool, **ppool;
        struct rspamd_async_session       *session, **psession;
        struct event_base                         *base, **pbase;
index 33caefad33a0f8006fa53034c9185fe7a25567de..2642daf9a82056871a523777ab8ac7675edf92ce 100644 (file)
@@ -53,7 +53,7 @@ static const struct luaL_reg    redislib_m[] = {
 struct lua_redis_userdata {
        redisAsyncContext *ctx;
        lua_State *L;
-       struct worker_task *task;
+       struct rspamd_task *task;
        gint cbref;
        gchar *server;
        struct in_addr ina;
@@ -68,12 +68,12 @@ struct lua_redis_userdata {
  * @param L lua stack
  * @return worker task object
  */
-static struct worker_task      *
+static struct rspamd_task      *
 lua_check_task (lua_State * L)
 {
        void                           *ud = luaL_checkudata (L, 1, "rspamd{task}");
        luaL_argcheck (L, ud != NULL, 1, "'task' expected");
-       return ud ? *((struct worker_task **)ud) : NULL;
+       return ud ? *((struct rspamd_task **)ud) : NULL;
 }
 
 static void
@@ -95,11 +95,11 @@ lua_redis_fin (void *arg)
 static void
 lua_redis_push_error (const gchar *err, struct lua_redis_userdata *ud, gboolean connected)
 {
-       struct worker_task                                      **ptask;
+       struct rspamd_task                                      **ptask;
 
        /* Push error */
        lua_rawgeti (ud->L, LUA_REGISTRYINDEX, ud->cbref);
-       ptask = lua_newuserdata (ud->L, sizeof (struct worker_task *));
+       ptask = lua_newuserdata (ud->L, sizeof (struct rspamd_task *));
        lua_setclass (ud->L, "rspamd{task}", -1);
 
        *ptask = ud->task;
@@ -125,11 +125,11 @@ lua_redis_push_error (const gchar *err, struct lua_redis_userdata *ud, gboolean
 static void
 lua_redis_push_data (const redisReply *r, struct lua_redis_userdata *ud)
 {
-       struct worker_task                                      **ptask;
+       struct rspamd_task                                      **ptask;
 
        /* Push error */
        lua_rawgeti (ud->L, LUA_REGISTRYINDEX, ud->cbref);
-       ptask = lua_newuserdata (ud->L, sizeof (struct worker_task *));
+       ptask = lua_newuserdata (ud->L, sizeof (struct rspamd_task *));
        lua_setclass (ud->L, "rspamd{task}", -1);
 
        *ptask = ud->task;
@@ -271,7 +271,7 @@ lua_redis_dns_callback (struct rdns_reply *reply, gpointer arg)
 static int
 lua_redis_make_request (lua_State *L)
 {
-       struct worker_task                                      *task;
+       struct rspamd_task                                      *task;
        struct lua_redis_userdata                       *ud;
        const gchar                                                     *server, *tmp;
        guint                                                            port, i;
index 075260359c2de29507765fc70083bafa2b713bc7..de42989daa44c28ce786f35c27ee0acf4fc05f90 100644 (file)
@@ -220,12 +220,12 @@ static const struct luaL_reg    urllib_m[] = {
 };
 
 /* Utility functions */
-static struct worker_task      *
+static struct rspamd_task      *
 lua_check_task (lua_State * L)
 {
        void                           *ud = luaL_checkudata (L, 1, "rspamd{task}");
        luaL_argcheck (L, ud != NULL, 1, "'task' expected");
-       return ud ? *((struct worker_task **)ud) : NULL;
+       return ud ? *((struct rspamd_task **)ud) : NULL;
 }
 
 static struct mime_text_part   *
@@ -265,7 +265,7 @@ lua_check_url (lua_State * L)
 static int
 lua_task_create_empty (lua_State *L)
 {
-       struct worker_task             **ptask, *task;
+       struct rspamd_task             **ptask, *task;
 
        task = construct_task (NULL);
        ptask = lua_newuserdata (L, sizeof (gpointer));
@@ -277,7 +277,7 @@ lua_task_create_empty (lua_State *L)
 static int
 lua_task_create_from_buffer (lua_State *L)
 {
-       struct worker_task             **ptask, *task;
+       struct rspamd_task             **ptask, *task;
        const gchar                                             *data;
        size_t                                                   len;
 
@@ -295,7 +295,7 @@ lua_task_create_from_buffer (lua_State *L)
 static int
 lua_task_process_message (lua_State *L)
 {
-       struct worker_task             *task = lua_check_task (L);
+       struct rspamd_task             *task = lua_check_task (L);
 
        if (task != NULL && task->msg != NULL && task->msg->len > 0) {
                if (process_message (task) == 0) {
@@ -314,7 +314,7 @@ lua_task_process_message (lua_State *L)
 static int
 lua_task_set_cfg (lua_State *L)
 {
-       struct worker_task             *task = lua_check_task (L);
+       struct rspamd_task             *task = lua_check_task (L);
        void                           *ud = luaL_checkudata (L, 2, "rspamd{config}");
 
        luaL_argcheck (L, ud != NULL, 1, "'config' expected");
@@ -325,7 +325,7 @@ lua_task_set_cfg (lua_State *L)
 static int
 lua_task_destroy (lua_State *L)
 {
-       struct worker_task             *task = lua_check_task (L);
+       struct rspamd_task             *task = lua_check_task (L);
 
        if (task != NULL) {
                free_task (task, FALSE);
@@ -338,7 +338,7 @@ static int
 lua_task_get_message (lua_State * L)
 {
        GMimeMessage                  **pmsg;
-       struct worker_task             *task = lua_check_task (L);
+       struct rspamd_task             *task = lua_check_task (L);
 
        if (task != NULL && task->message != NULL) {
                pmsg = lua_newuserdata (L, sizeof (GMimeMessage *));
@@ -355,7 +355,7 @@ static int
 lua_task_get_mempool (lua_State * L)
 {
        rspamd_mempool_t                  **ppool;
-       struct worker_task             *task = lua_check_task (L);
+       struct rspamd_task             *task = lua_check_task (L);
 
        if (task != NULL) {
                ppool = lua_newuserdata (L, sizeof (rspamd_mempool_t *));
@@ -372,7 +372,7 @@ static int
 lua_task_get_session (lua_State * L)
 {
        struct rspamd_async_session   **psession;
-       struct worker_task             *task = lua_check_task (L);
+       struct rspamd_task             *task = lua_check_task (L);
 
        if (task != NULL) {
                psession = lua_newuserdata (L, sizeof (void *));
@@ -389,7 +389,7 @@ static int
 lua_task_get_ev_base (lua_State * L)
 {
        struct event_base             **pbase;
-       struct worker_task             *task = lua_check_task (L);
+       struct rspamd_task             *task = lua_check_task (L);
 
        if (task != NULL) {
                pbase = lua_newuserdata (L, sizeof (struct event_base *));
@@ -405,7 +405,7 @@ lua_task_get_ev_base (lua_State * L)
 static gint
 lua_task_insert_result (lua_State * L)
 {
-       struct worker_task             *task = lua_check_task (L);
+       struct rspamd_task             *task = lua_check_task (L);
        const gchar                     *symbol_name, *param;
        double                          flag;
        GList                          *params = NULL;
@@ -429,7 +429,7 @@ lua_task_insert_result (lua_State * L)
 static gint
 lua_task_set_pre_result (lua_State * L)
 {
-       struct worker_task                              *task = lua_check_task (L);
+       struct rspamd_task                              *task = lua_check_task (L);
        gchar                               *action_str;
        guint                            action;
 
@@ -471,7 +471,7 @@ lua_tree_url_callback (gpointer key, gpointer value, gpointer ud)
 static gint
 lua_task_get_urls (lua_State * L)
 {
-       struct worker_task             *task = lua_check_task (L);
+       struct rspamd_task             *task = lua_check_task (L);
        struct lua_tree_cb_data         cb;
 
        if (task) {
@@ -489,7 +489,7 @@ lua_task_get_urls (lua_State * L)
 static gint
 lua_task_get_emails (lua_State * L)
 {
-       struct worker_task             *task = lua_check_task (L);
+       struct rspamd_task             *task = lua_check_task (L);
        struct lua_tree_cb_data         cb;
 
        if (task) {
@@ -508,7 +508,7 @@ static gint
 lua_task_get_text_parts (lua_State * L)
 {
        gint                            i = 1;
-       struct worker_task             *task = lua_check_task (L);
+       struct rspamd_task             *task = lua_check_task (L);
        GList                          *cur;
        struct mime_text_part          *part, **ppart;
 
@@ -534,7 +534,7 @@ static gint
 lua_task_get_parts (lua_State * L)
 {
        gint                            i = 1;
-       struct worker_task             *task = lua_check_task (L);
+       struct rspamd_task             *task = lua_check_task (L);
        GList                          *cur;
        struct mime_part          *part, **ppart;
 
@@ -560,7 +560,7 @@ lua_task_get_parts (lua_State * L)
 static gint
 lua_task_get_raw_headers (lua_State * L)
 {
-       struct worker_task             *task = lua_check_task (L);
+       struct rspamd_task             *task = lua_check_task (L);
 
        if (task) {
                lua_pushstring (L, task->raw_headers_str);
@@ -575,7 +575,7 @@ lua_task_get_raw_headers (lua_State * L)
 static gint
 lua_task_get_raw_header_common (lua_State * L, gboolean strong)
 {
-       struct worker_task             *task = lua_check_task (L);
+       struct rspamd_task             *task = lua_check_task (L);
        struct raw_header                          *rh;
        gint                            i = 1;
        const gchar                    *name;
@@ -649,7 +649,7 @@ lua_task_get_raw_header_strong (lua_State * L)
 static gint
 lua_task_get_received_headers (lua_State * L)
 {
-       struct worker_task             *task = lua_check_task (L);
+       struct rspamd_task             *task = lua_check_task (L);
        GList                          *cur;
        struct received_header         *rh;
        gint                            i = 1;
@@ -691,7 +691,7 @@ lua_task_get_received_headers (lua_State * L)
 static gint
 lua_task_get_resolver (lua_State *L)
 {
-       struct worker_task             *task = lua_check_task (L);
+       struct rspamd_task             *task = lua_check_task (L);
        struct rspamd_dns_resolver    **presolver;
 
        if (task != NULL && task->resolver != NULL) {
@@ -709,7 +709,7 @@ lua_task_get_resolver (lua_State *L)
 static gint
 lua_task_inc_dns_req (lua_State *L)
 {
-       struct worker_task             *task = lua_check_task (L);
+       struct rspamd_task             *task = lua_check_task (L);
 
        if (task != NULL) {
                task->dns_requests ++;
@@ -721,7 +721,7 @@ lua_task_inc_dns_req (lua_State *L)
 static gint
 lua_task_call_rspamd_function (lua_State * L)
 {
-       struct worker_task             *task = lua_check_task (L);
+       struct rspamd_task             *task = lua_check_task (L);
        struct expression_function      f;
        gint                            i, top;
        gboolean                        res;
@@ -823,7 +823,7 @@ lua_push_internet_address_list (lua_State *L, InternetAddressList *addrs)
 static gint
 lua_task_get_recipients (lua_State *L)
 {
-       struct worker_task             *task = lua_check_task (L);
+       struct rspamd_task             *task = lua_check_task (L);
        GList                          *cur;
        InternetAddressList            *addrs;
        gint                            idx = 1;
@@ -864,7 +864,7 @@ lua_task_get_recipients (lua_State *L)
 static gint
 lua_task_get_from (lua_State *L)
 {
-       struct worker_task             *task = lua_check_task (L);
+       struct rspamd_task             *task = lua_check_task (L);
        InternetAddressList            *addrs;
        
        if (task) {
@@ -897,7 +897,7 @@ lua_task_get_from (lua_State *L)
 static gint
 lua_task_set_from (lua_State *L)
 {
-       struct worker_task             *task = lua_check_task (L);
+       struct rspamd_task             *task = lua_check_task (L);
        const gchar                                        *new_from;
 
        if (task) {
@@ -913,7 +913,7 @@ lua_task_set_from (lua_State *L)
 static gint
 lua_task_get_user (lua_State *L)
 {
-       struct worker_task             *task = lua_check_task (L);
+       struct rspamd_task             *task = lua_check_task (L);
 
        if (task && task->user != NULL) {
                lua_pushstring (L, task->user);
@@ -927,7 +927,7 @@ lua_task_get_user (lua_State *L)
 static gint
 lua_task_set_user (lua_State *L)
 {
-       struct worker_task             *task = lua_check_task (L);
+       struct rspamd_task             *task = lua_check_task (L);
        const gchar                                        *new_user;
 
        if (task) {
@@ -946,7 +946,7 @@ lua_task_set_user (lua_State *L)
 static gint
 lua_task_get_recipients_headers (lua_State *L)
 {
-       struct worker_task             *task = lua_check_task (L);
+       struct rspamd_task             *task = lua_check_task (L);
 
        if (task && task->rcpts) {
                lua_push_internet_address_list (L, task->rcpts);
@@ -960,7 +960,7 @@ lua_task_get_recipients_headers (lua_State *L)
 static gint
 lua_task_get_from_headers (lua_State *L)
 {
-       struct worker_task             *task = lua_check_task (L);
+       struct rspamd_task             *task = lua_check_task (L);
        InternetAddressList            *addrs;
 
        if (task && task->message != NULL) {
@@ -990,7 +990,7 @@ lua_task_get_from_headers (lua_State *L)
 static gint
 lua_task_get_from_ip (lua_State *L)
 {
-       struct worker_task             *task = lua_check_task (L);
+       struct rspamd_task             *task = lua_check_task (L);
        
        if (task) {
                lua_ip_push (L, task->from_addr.ipv6 ? AF_INET6 : AF_INET, &task->from_addr.d);
@@ -1020,7 +1020,7 @@ lua_task_get_from_ip_num (lua_State *L)
 static gint
 lua_task_get_client_ip_num (lua_State *L)
 {
-       struct worker_task             *task = lua_check_task (L);
+       struct rspamd_task             *task = lua_check_task (L);
        
        if (task) {
                lua_ip_push (L, AF_INET, &task->client_addr);
@@ -1035,7 +1035,7 @@ lua_task_get_client_ip_num (lua_State *L)
 static gint
 lua_task_get_helo (lua_State *L)
 {
-       struct worker_task             *task = lua_check_task (L);
+       struct rspamd_task             *task = lua_check_task (L);
        
        if (task) {
                if (task->helo != NULL) {
@@ -1051,7 +1051,7 @@ lua_task_get_helo (lua_State *L)
 static gint
 lua_task_set_helo (lua_State *L)
 {
-       struct worker_task             *task = lua_check_task (L);
+       struct rspamd_task             *task = lua_check_task (L);
        const gchar                                        *new_helo;
 
        if (task) {
@@ -1067,7 +1067,7 @@ lua_task_set_helo (lua_State *L)
 static gint
 lua_task_get_hostname (lua_State *L)
 {
-       struct worker_task             *task = lua_check_task (L);
+       struct rspamd_task             *task = lua_check_task (L);
 
        if (task) {
                if (task->hostname != NULL) {
@@ -1097,7 +1097,7 @@ lua_task_get_hostname (lua_State *L)
 static gint
 lua_task_set_hostname (lua_State *L)
 {
-       struct worker_task             *task = lua_check_task (L);
+       struct rspamd_task             *task = lua_check_task (L);
        const gchar                                        *new_hostname;
 
        if (task) {
@@ -1113,7 +1113,7 @@ lua_task_set_hostname (lua_State *L)
 static gint
 lua_task_get_images (lua_State *L)
 {
-       struct worker_task             *task = lua_check_task (L);
+       struct rspamd_task             *task = lua_check_task (L);
        gint                            i = 1;
        GList                          *cur;
        struct rspamd_image           **pimg;
@@ -1138,7 +1138,7 @@ lua_task_get_images (lua_State *L)
 }
 
 static inline gboolean
-lua_push_symbol_result (lua_State *L, struct worker_task *task, struct metric *metric, const gchar *symbol)
+lua_push_symbol_result (lua_State *L, struct rspamd_task *task, struct metric *metric, const gchar *symbol)
 {
        struct metric_result           *metric_res;
        struct symbol                  *s;
@@ -1178,7 +1178,7 @@ lua_push_symbol_result (lua_State *L, struct worker_task *task, struct metric *m
 static gint
 lua_task_get_symbol (lua_State *L)
 {
-       struct worker_task             *task = lua_check_task (L);
+       struct rspamd_task             *task = lua_check_task (L);
        const gchar                     *symbol;
        struct metric                  *metric;
        GList                          *cur = NULL, *metric_list;
@@ -1224,7 +1224,7 @@ lua_task_get_symbol (lua_State *L)
 static gint
 lua_task_get_date (lua_State *L)
 {
-       struct worker_task             *task = lua_check_task (L);
+       struct rspamd_task             *task = lua_check_task (L);
        time_t                          task_time;
 
        if (task != NULL) {
@@ -1242,7 +1242,7 @@ lua_task_get_date (lua_State *L)
 static gint
 lua_task_get_message_id (lua_State *L)
 {
-       struct worker_task             *task = lua_check_task (L);
+       struct rspamd_task             *task = lua_check_task (L);
 
        if (task != NULL && task->message_id != NULL) {
                lua_pushstring (L, task->message_id);
@@ -1257,7 +1257,7 @@ lua_task_get_message_id (lua_State *L)
 static gint
 lua_task_get_timeval (lua_State *L)
 {
-       struct worker_task             *task = lua_check_task (L);
+       struct rspamd_task             *task = lua_check_task (L);
 
        if (task != NULL) {
                lua_newtable (L);
@@ -1279,7 +1279,7 @@ lua_task_get_timeval (lua_State *L)
 static gint
 lua_task_learn_statfile (lua_State *L)
 {
-       struct worker_task             *task = lua_check_task (L);
+       struct rspamd_task             *task = lua_check_task (L);
        const gchar                     *symbol;
        struct classifier_config       *cl;
        GTree                          *tokens;
@@ -1322,7 +1322,7 @@ lua_task_learn_statfile (lua_State *L)
 static gint
 lua_task_get_metric_score (lua_State *L)
 {
-       struct worker_task             *task = lua_check_task (L);
+       struct rspamd_task             *task = lua_check_task (L);
        const gchar                     *metric_name;
        struct metric_result           *metric_res;
 
@@ -1350,7 +1350,7 @@ lua_task_get_metric_score (lua_State *L)
 static gint
 lua_task_get_metric_action (lua_State *L)
 {
-       struct worker_task             *task = lua_check_task (L);
+       struct rspamd_task             *task = lua_check_task (L);
        const gchar                     *metric_name;
        struct metric_result           *metric_res;
        enum rspamd_metric_action       action;
index ec132fa9d547f584549c1f814f0aec9c120a69c5..44b2126647595004b0d82d7ee8da0354f1c88f6a 100644 (file)
@@ -21,6 +21,7 @@
 #include "logger.h"
 #include "roll_history.h"
 #include "http.h"
+#include "task.h"
 
 /* Default values */
 #define FIXED_CONFIG_FILE RSPAMD_CONFDIR "/rspamd.conf"
@@ -71,7 +72,7 @@ struct classifier_config;
 struct mime_part;
 struct rspamd_view;
 struct rspamd_dns_resolver;
-struct worker_task;
+struct rspamd_task;
 
 /** 
  * Server statistics
@@ -165,112 +166,16 @@ struct controller_session {
        void *other_data;                                                                                       /**< and its data                                                                       */
        controller_func_t custom_handler;                                                       /**< custom command handler                                                     */
        struct rspamd_async_session* s;                                                         /**< async session object                                                       */
-       struct worker_task *learn_task;
+       struct rspamd_task *learn_task;
        struct rspamd_dns_resolver *resolver;                                           /**< DNS resolver                                                                       */
        struct event_base *ev_base;                                                                     /**< Event base                                                                         */
 };
 
-/**
- * Worker task structure
- */
-struct worker_task {
-       struct rspamd_worker *worker;                                                           /**< pointer to worker object                                           */
-       enum {
-               READ_MESSAGE,
-               WAIT_PRE_FILTER,
-               WAIT_FILTER,
-               WAIT_POST_FILTER,
-               WRITE_REPLY,
-               CLOSING_CONNECTION
-       } state;                                                                                                        /**< current session state                                                      */
-       enum rspamd_command cmd;                                                                        /**< command                                                                            */
-       struct custom_command *custom_cmd;                                                      /**< custom command if any                                                      */      
-       gint sock;                                                                                                      /**< socket descriptor                                                          */
-       gboolean is_mime;                                           /**< if this task is mime task                      */
-       gboolean is_json;                                                                                       /**< output is JSON                                                                     */
-       gboolean allow_learn;                                                                           /**< allow learning                                                                     */
-       gboolean is_skipped;                                        /**< whether message was skipped by configuration   */
-
-       gchar *helo;                                                                                                    /**< helo header value                                                          */
-       gchar *from;                                                                                                    /**< from header value                                                          */
-       gchar *queue_id;                                                                                                /**< queue id if specified                                                      */
-       const gchar *message_id;                                                                                /**< message id                                                                         */
-       GList *rcpt;                                                                                                    /**< recipients list                                                            */
-       guint nrcpt;                                                                                    /**< number of recipients                                                       */
-#ifdef HAVE_INET_PTON
-       struct {
-               union {
-                       struct in_addr in4;
-                       struct in6_addr in6;
-               } d;
-               gboolean ipv6;
-               gboolean has_addr;
-       } from_addr;
-#else
-       struct in_addr from_addr;                                                                       /**< client addr in numeric form                                        */
-#endif
-       struct in_addr client_addr;                                                                     /**< client addr in numeric form                                        */
-       gchar *deliver_to;                                                                                      /**< address to deliver                                                         */
-       gchar *user;                                                                                                    /**< user to deliver                                                            */
-       gchar *subject;                                                                                         /**< subject (for non-mime)                                                     */
-       gchar *hostname;                                                                                        /**< hostname reported by MTA                                           */
-       GString *msg;                                                                                           /**< message buffer                                                                     */
-       rspamd_io_dispatcher_t *dispatcher;                                                     /**< IO dispatcher object                                                       */
-       struct rspamd_http_connection *http_conn;                                       /**< HTTP server connection                                                     */
-       struct rspamd_async_session* s;                                                         /**< async session object                                                       */
-       gint parts_count;                                                                                       /**< mime parts count                                                           */
-       GMimeMessage *message;                                                                          /**< message, parsed with GMime                                         */
-       GMimeObject *parser_parent_part;                                                        /**< current parent part                                                        */
-       InternetAddressList *rcpts;                                                                     /**< list of all recipients                                             */
-       GList *parts;                                                                                           /**< list of parsed parts                                                       */
-       GList *text_parts;                                                                                      /**< list of text parts                                                         */
-       gchar *raw_headers_str;                                                                                 /**< list of raw headers                                                        */
-       GList *received;                                                                                        /**< list of received headers                                           */
-       GTree *urls;                                                                                            /**< list of parsed urls                                                        */
-       GTree *emails;                                                                                          /**< list of parsed emails                                                      */
-       GList *images;                                                                                          /**< list of images                                                                     */
-       GHashTable *raw_headers;                                                                        /**< list of raw headers                                                        */
-       GHashTable *results;                                                                            /**< hash table of metric_result indexed by 
-        *    metric's name                                                                     */
-       GHashTable *tokens;                                                                                     /**< hash table of tokens indexed by tokenizer
-        *    pointer                                                                           */
-       GList *messages;                                                                                        /**< list of messages that would be reported            */
-       GHashTable *re_cache;                                                                           /**< cache for matched or not matched regexps           */
-       struct config_file *cfg;                                                                        /**< pointer to config object                                           */
-       gchar *last_error;                                                                                      /**< last error                                                                         */
-       gint error_code;                                                                                                /**< code of last error                                                         */
-       rspamd_mempool_t *task_pool;                                                                    /**< memory pool for task                                                       */
-#ifdef HAVE_CLOCK_GETTIME
-       struct timespec ts;                                                                                     /**< time of connection                                                         */
-#endif
-       struct timeval tv;                                                                                      /**< time of connection                                                         */
-       struct rspamd_view *view;                                                                       /**< matching view                                                                      */
-       guint32 scan_milliseconds;                                                                      /**< how much milliseconds passed                                       */
-       gboolean view_checked;
-       gboolean pass_all_filters;                                                                      /**< pass task throught every rule                                      */
-       gboolean no_log;                                                                                        /**< do not log or write this task to the history       */
-       guint32 parser_recursion;                                                                       /**< for avoiding recursion stack overflow                      */
-       gboolean (*fin_callback)(void *arg);                                            /**< calback for filters finalizing                                     */
-       void *fin_arg;                                                                                          /**< argument for fin callback                                          */
-
-       guint32 dns_requests;                                                                           /**< number of DNS requests per this task                       */
-
-       struct rspamd_dns_resolver *resolver;                                           /**< DNS resolver                                                                       */
-       struct event_base *ev_base;                                                                     /**< Event base                                                                         */
-
-       GThreadPool *classify_pool;                                                                     /**< A pool of classify threads                                         */
-
-       struct {
-               enum rspamd_metric_action action;                                               /**< Action of pre filters                                                      */
-               gchar *str;                                                                                             /**< String describing action                                           */
-       } pre_result;                                                                                           /**< Result of pre-filters                                                      */
-};
-
 /**
  * Common structure representing C module context
  */
 struct module_ctx {
-       gint (*filter)(struct worker_task *task);                                       /**< pointer to headers process function                        */
+       gint (*filter)(struct rspamd_task *task);                                       /**< pointer to headers process function                        */
 };
 
 /**
@@ -296,11 +201,11 @@ extern struct rspamd_main *rspamd_main;
 /**
  * Construct new task for worker
  */
-struct worker_task* construct_task (struct rspamd_worker *worker);
+struct rspamd_task* construct_task (struct rspamd_worker *worker);
 /**
  * Destroy task object and remove its IO dispatcher if it exists
  */
-void free_task (struct worker_task *task, gboolean is_soft);
+void free_task (struct rspamd_task *task, gboolean is_soft);
 void free_task_hard (gpointer ud);
 void free_task_soft (gpointer ud);
 
index b8d9d9d134ec3907f5ea9d31011fa52650dda741..4567869e9871ea6be226ba6d2480072f0e040ece 100644 (file)
@@ -34,7 +34,7 @@
 #define UTF8_CHARSET "UTF-8"
 
 GByteArray                     *
-strip_html_tags (struct worker_task *task, rspamd_mempool_t * pool, struct mime_text_part *part, GByteArray * src, gint *stateptr)
+strip_html_tags (struct rspamd_task *task, rspamd_mempool_t * pool, struct mime_text_part *part, GByteArray * src, gint *stateptr)
 {
        uint8_t                        *p, *rp, *tbegin = NULL, *end, c, lc;
        gint                            br, i = 0, depth = 0, in_q = 0;
@@ -550,7 +550,7 @@ parse_recv_header (rspamd_mempool_t * pool, gchar *line, struct received_header
 
 /* Convert raw headers to a list of struct raw_header * */
 static void
-process_raw_headers (struct worker_task *task)
+process_raw_headers (struct rspamd_task *task)
 {
        struct raw_header              *new = NULL, *lp;
        gchar                          *p, *c, *tmp, *tp;
@@ -774,7 +774,7 @@ free_byte_array_callback (void *pointer)
 }
 
 static GByteArray              *
-convert_text_to_utf (struct worker_task *task, GByteArray * part_content, GMimeContentType * type, struct mime_text_part *text_part)
+convert_text_to_utf (struct rspamd_task *task, GByteArray * part_content, GMimeContentType * type, struct mime_text_part *text_part)
 {
        GError                         *err = NULL;
        gsize                           read_bytes, write_bytes;
@@ -823,7 +823,7 @@ convert_text_to_utf (struct worker_task *task, GByteArray * part_content, GMimeC
 }
 
 static void
-process_text_part (struct worker_task *task, GByteArray *part_content, GMimeContentType *type,
+process_text_part (struct rspamd_task *task, GByteArray *part_content, GMimeContentType *type,
                GMimeObject *part, GMimeObject *parent, gboolean is_empty)
 {
        struct mime_text_part          *text_part;
@@ -907,7 +907,7 @@ static void
 mime_foreach_callback (GMimeObject * part, gpointer user_data)
 #endif
 {
-       struct worker_task             *task = (struct worker_task *)user_data;
+       struct rspamd_task             *task = (struct rspamd_task *)user_data;
        struct mime_part               *mime_part;
        GMimeContentType               *type;
        GMimeDataWrapper               *wrapper;
@@ -1032,7 +1032,7 @@ destroy_message (void *pointer)
 }
 
 gint
-process_message (struct worker_task *task)
+process_message (struct rspamd_task *task)
 {
        GMimeMessage                   *message;
        GMimeParser                    *parser;
@@ -1731,7 +1731,7 @@ message_get_header (rspamd_mempool_t * pool, GMimeMessage * message, const gchar
 }
 
 GList*
-message_get_raw_header (struct worker_task *task, const gchar *field, gboolean strong)
+message_get_raw_header (struct rspamd_task *task, const gchar *field, gboolean strong)
 {
        GList                               *gret = NULL;
        struct raw_header                   *rh;
index f77c9082536063e1c4eb3aacf36d382bf19a982e..5e27579d109cc744ab6f39234ea22cab010c4463 100644 (file)
@@ -9,7 +9,7 @@
 #include "config.h"
 #include "fuzzy.h"
 
-struct worker_task;
+struct rspamd_task;
 struct controller_session;
 
 struct mime_part {
@@ -62,7 +62,7 @@ struct raw_header {
  * @param task worker_task object
  * @return 0 if we have delayed filters to process and 1 if we have finished with processing
  */
-gint process_message (struct worker_task *task);
+gint process_message (struct rspamd_task *task);
 
 /*
  * Set header with specified name and value
@@ -86,6 +86,6 @@ GList* message_get_header (rspamd_mempool_t *pool, GMimeMessage *message, const
  * @param strong if this flag is TRUE header's name is case sensitive, otherwise it is not
  * @return A list of header's values or NULL. Unlike previous function it is NOT required to free list or values. I should rework one of these functions some time.
  */
-GList* message_get_raw_header (struct worker_task *task, const gchar *field, gboolean strong);
+GList* message_get_raw_header (struct rspamd_task *task, const gchar *field, gboolean strong);
 
 #endif
index fc9ff3f49db10de6c30c39bcabfc3c3c789b83e3..937cf1dc07bceee4ff771392a73db04535e14253 100644 (file)
@@ -54,7 +54,7 @@ module_t chartable_module = {
 };
 
 struct chartable_ctx {
-       gint                            (*filter) (struct worker_task * task);
+       gint                            (*filter) (struct rspamd_task * task);
        const gchar                    *symbol;
        double                          threshold;
 
@@ -63,8 +63,8 @@ struct chartable_ctx {
 
 static struct chartable_ctx    *chartable_module_ctx = NULL;
 
-static gint                      chartable_mime_filter (struct worker_task *task);
-static void                     chartable_symbol_callback (struct worker_task *task, void *unused);
+static gint                      chartable_mime_filter (struct rspamd_task *task);
+static void                     chartable_symbol_callback (struct rspamd_task *task, void *unused);
 
 gint
 chartable_module_init (struct config_file *cfg, struct module_ctx **ctx)
@@ -197,7 +197,7 @@ check_part (struct mime_text_part *part, gboolean raw_mode)
 }
 
 static void
-chartable_symbol_callback (struct worker_task *task, void *unused)
+chartable_symbol_callback (struct rspamd_task *task, void *unused)
 {
        GList                          *cur;
        struct mime_text_part          *part;
@@ -216,7 +216,7 @@ chartable_symbol_callback (struct worker_task *task, void *unused)
 }
 
 static gint
-chartable_mime_filter (struct worker_task *task)
+chartable_mime_filter (struct rspamd_task *task)
 {
        /* XXX: remove it */
        return 0;
index eb6cefb7dbd11e79196d97c80290dc13b040886c..9610db6a8701863614ce68ad416902fb92be2549 100644 (file)
@@ -56,7 +56,7 @@
 #define DEFAULT_TIME_JITTER 60
 
 struct dkim_ctx {
-       gint                            (*filter) (struct worker_task * task);
+       gint                            (*filter) (struct rspamd_task * task);
        const gchar                    *symbol_reject;
        const gchar                    *symbol_tempfail;
        const gchar                    *symbol_allow;
@@ -73,7 +73,7 @@ struct dkim_ctx {
 
 static struct dkim_ctx        *dkim_module_ctx = NULL;
 
-static void                   dkim_symbol_callback (struct worker_task *task, void *unused);
+static void                   dkim_symbol_callback (struct rspamd_task *task, void *unused);
 
 /* Initialization */
 gint dkim_module_init (struct config_file *cfg, struct module_ctx **ctx);
@@ -238,7 +238,7 @@ dkim_module_parse_strict (const gchar *value, gint *allow, gint *deny)
 }
 
 static void
-dkim_module_check (struct worker_task *task, rspamd_dkim_context_t *ctx, rspamd_dkim_key_t *key)
+dkim_module_check (struct rspamd_task *task, rspamd_dkim_context_t *ctx, rspamd_dkim_key_t *key)
 {
        gint                                                             res, score_allow = 1, score_deny = 1;
        const gchar                                                     *strict_value;
@@ -275,7 +275,7 @@ dkim_module_check (struct worker_task *task, rspamd_dkim_context_t *ctx, rspamd_
 static void
 dkim_module_key_handler (rspamd_dkim_key_t *key, gsize keylen, rspamd_dkim_context_t *ctx, gpointer ud, GError *err)
 {
-       struct worker_task                                      *task = ud;
+       struct rspamd_task                                      *task = ud;
 
 
        if (key != NULL) {
@@ -303,7 +303,7 @@ dkim_module_key_handler (rspamd_dkim_key_t *key, gsize keylen, rspamd_dkim_conte
 }
 
 static void
-dkim_symbol_callback (struct worker_task *task, void *unused)
+dkim_symbol_callback (struct rspamd_task *task, void *unused)
 {
        GList                                                           *hlist;
        rspamd_dkim_context_t                           *ctx;
index 663613e4c034475c0a78fc25a183b5b533ad372c..595cfc99b5142932fffcb30e96cda256cf1d1613 100644 (file)
@@ -88,7 +88,7 @@ struct fuzzy_rule {
 };
 
 struct fuzzy_ctx {
-       gint (*filter) (struct worker_task * task);
+       gint (*filter) (struct rspamd_task * task);
        rspamd_mempool_t *fuzzy_pool;
        GList *fuzzy_rules;
        const gchar *default_symbol;
@@ -105,7 +105,7 @@ struct fuzzy_client_session {
        fuzzy_hash_t *h;
        struct event ev;
        struct timeval tv;
-       struct worker_task *task;
+       struct rspamd_task *task;
        struct storage_server *server;
        struct fuzzy_rule *rule;
        gint fd;
@@ -123,14 +123,14 @@ struct fuzzy_learn_session {
        struct controller_session *session;
        struct storage_server *server;
        struct fuzzy_rule *rule;
-       struct worker_task *task;
+       struct rspamd_task *task;
        gint fd;
 };
 
 static struct fuzzy_ctx *fuzzy_module_ctx = NULL;
 static const gchar hex_digits[] = "0123456789abcdef";
 
-static void fuzzy_symbol_callback (struct worker_task *task, void *unused);
+static void fuzzy_symbol_callback (struct rspamd_task *task, void *unused);
 static gboolean fuzzy_add_handler (gchar **args, struct controller_session *session);
 static gboolean fuzzy_delete_handler (gchar **args,
                struct controller_session *session);
@@ -691,7 +691,7 @@ ok:
 }
 
 static inline void
-register_fuzzy_call (struct worker_task *task, struct fuzzy_rule *rule, fuzzy_hash_t *h)
+register_fuzzy_call (struct rspamd_task *task, struct fuzzy_rule *rule, fuzzy_hash_t *h)
 {
        struct fuzzy_client_session    *session;
        struct storage_server          *selected;
@@ -730,7 +730,7 @@ register_fuzzy_call (struct worker_task *task, struct fuzzy_rule *rule, fuzzy_ha
 }
 
 static void
-fuzzy_check_rule (struct worker_task *task, struct fuzzy_rule *rule)
+fuzzy_check_rule (struct rspamd_task *task, struct fuzzy_rule *rule)
 {
        struct mime_text_part          *part;
        struct mime_part               *mime_part;
@@ -816,7 +816,7 @@ fuzzy_check_rule (struct worker_task *task, struct fuzzy_rule *rule)
 
 /* This callback is called when we check message via fuzzy hashes storage */
 static void
-fuzzy_symbol_callback (struct worker_task *task, void *unused)
+fuzzy_symbol_callback (struct rspamd_task *task, void *unused)
 {
        struct fuzzy_rule *rule;
        GList *cur;
@@ -850,7 +850,7 @@ fuzzy_symbol_callback (struct worker_task *task, void *unused)
 
 static inline gboolean
 register_fuzzy_controller_call (struct controller_session *session,
-               struct fuzzy_rule *rule, struct worker_task *task, fuzzy_hash_t *h,
+               struct fuzzy_rule *rule, struct rspamd_task *task, fuzzy_hash_t *h,
                gint cmd, gint value, gint flag, gint *saved, GError **err)
 {
        struct fuzzy_learn_session     *s;
@@ -903,7 +903,7 @@ register_fuzzy_controller_call (struct controller_session *session,
 
 static int
 fuzzy_process_rule (struct controller_session *session, struct fuzzy_rule *rule,
-               struct worker_task *task, GError **err, gint cmd, gint flag, gint value, gint *saved)
+               struct rspamd_task *task, GError **err, gint cmd, gint flag, gint value, gint *saved)
 {
        struct mime_text_part          *part;
        struct mime_part               *mime_part;
@@ -1002,7 +1002,7 @@ fuzzy_process_handler (struct controller_session *session, f_str_t * in)
        struct fuzzy_rule *rule;
        gboolean processed = FALSE, res = TRUE;
        GList *cur;
-       struct worker_task *task;
+       struct rspamd_task *task;
        GError **err;
        gint r, cmd = 0, value = 0, flag = 0, *saved, *sargs;
        gchar out_buf[BUFSIZ];
index 2a7978c7315a9a085b2f29407329a35416a4d878..0229236f69eab890dcb3ea9da9dcd59c27652e18 100644 (file)
@@ -54,7 +54,7 @@ struct autolearn_data {
 };
 
 struct regexp_ctx {
-       gint                          (*filter) (struct worker_task * task);
+       gint                          (*filter) (struct rspamd_task * task);
        GHashTable                     *autolearn_symbols;
        gchar                          *statfile_prefix;
 
@@ -84,19 +84,19 @@ static const struct luaL_reg    regexplib_m[] = {
 static struct regexp_ctx       *regexp_module_ctx = NULL;
 static GMutex                             *workers_mtx = NULL;
 
-static gint                     regexp_common_filter (struct worker_task *task);
+static gint                     regexp_common_filter (struct rspamd_task *task);
 static void                                 process_regexp_item_threaded (gpointer data, gpointer user_data);
-static gboolean                 rspamd_regexp_match_number (struct worker_task *task, GList * args, void *unused);
-static gboolean                 rspamd_raw_header_exists (struct worker_task *task, GList * args, void *unused);
-static gboolean                 rspamd_check_smtp_data (struct worker_task *task, GList * args, void *unused);
-static gboolean                 rspamd_regexp_occurs_number (struct worker_task *task, GList * args, void *unused);
-static gboolean                 rspamd_content_type_is_type (struct worker_task * task, GList * args, void *unused);
-static gboolean                 rspamd_content_type_is_subtype (struct worker_task *task, GList * args, void *unused);
-static gboolean                 rspamd_content_type_has_param (struct worker_task * task, GList * args, void *unused);
-static gboolean                 rspamd_content_type_compare_param (struct worker_task * task, GList * args, void *unused);
-static gboolean                 rspamd_has_content_part (struct worker_task *task, GList * args, void *unused);
-static gboolean                 rspamd_has_content_part_len (struct worker_task *task, GList * args, void *unused);
-static void                    process_regexp_item (struct worker_task *task, void *user_data);
+static gboolean                 rspamd_regexp_match_number (struct rspamd_task *task, GList * args, void *unused);
+static gboolean                 rspamd_raw_header_exists (struct rspamd_task *task, GList * args, void *unused);
+static gboolean                 rspamd_check_smtp_data (struct rspamd_task *task, GList * args, void *unused);
+static gboolean                 rspamd_regexp_occurs_number (struct rspamd_task *task, GList * args, void *unused);
+static gboolean                 rspamd_content_type_is_type (struct rspamd_task * task, GList * args, void *unused);
+static gboolean                 rspamd_content_type_is_subtype (struct rspamd_task *task, GList * args, void *unused);
+static gboolean                 rspamd_content_type_has_param (struct rspamd_task * task, GList * args, void *unused);
+static gboolean                 rspamd_content_type_compare_param (struct rspamd_task * task, GList * args, void *unused);
+static gboolean                 rspamd_has_content_part (struct rspamd_task *task, GList * args, void *unused);
+static gboolean                 rspamd_has_content_part_len (struct rspamd_task *task, GList * args, void *unused);
+static void                    process_regexp_item (struct rspamd_task *task, void *user_data);
 
 
 /* Initialization */
@@ -119,7 +119,7 @@ G_LOCK_DEFINE (task_cache_mtx);
 #endif
 
 void
-task_cache_add (struct worker_task *task, struct rspamd_regexp *re, gint32 result)
+task_cache_add (struct rspamd_task *task, struct rspamd_regexp *re, gint32 result)
 {
        if (result == 0) {
                result = -1;
@@ -139,7 +139,7 @@ task_cache_add (struct worker_task *task, struct rspamd_regexp *re, gint32 resul
 }
 
 gint32
-task_cache_check (struct worker_task *task, struct rspamd_regexp *re)
+task_cache_check (struct rspamd_task *task, struct rspamd_regexp *re)
 {
        gpointer                        res;
        gint32                          r;
@@ -179,7 +179,7 @@ luaopen_regexp (lua_State * L)
 }
 
 static void 
-regexp_dynamic_insert_result (struct worker_task *task, void *user_data)
+regexp_dynamic_insert_result (struct rspamd_task *task, void *user_data)
 {
        gchar                           *symbol = user_data;
                
@@ -639,7 +639,7 @@ regexp_module_reconfig (struct config_file *cfg)
 }
 
 struct url_regexp_param {
-       struct worker_task             *task;
+       struct rspamd_task             *task;
        GRegex                         *regexp;
        struct rspamd_regexp           *re;
        gboolean                        found;
@@ -671,7 +671,7 @@ tree_url_callback (gpointer key, gpointer value, void *data)
 }
 
 static                          gsize
-process_regexp (struct rspamd_regexp *re, struct worker_task *task, const gchar *additional,
+process_regexp (struct rspamd_regexp *re, struct rspamd_task *task, const gchar *additional,
                gint limit, int_compare_func f)
 {
        guint8                         *ct;
@@ -1025,14 +1025,14 @@ process_regexp (struct rspamd_regexp *re, struct worker_task *task, const gchar
 }
 
 static gboolean
-maybe_call_lua_function (const gchar *name, struct worker_task *task, lua_State *L)
+maybe_call_lua_function (const gchar *name, struct rspamd_task *task, lua_State *L)
 {
-       struct worker_task            **ptask;
+       struct rspamd_task            **ptask;
        gboolean                        res;
 
        lua_getglobal (L, name);
        if (lua_isfunction (L, -1)) {
-               ptask = lua_newuserdata (L, sizeof (struct worker_task *));
+               ptask = lua_newuserdata (L, sizeof (struct rspamd_task *));
                lua_setclass (L, "rspamd{task}", -1);
                *ptask = task;
                /* Call function */
@@ -1107,7 +1107,7 @@ optimize_regexp_expression (struct expression **e, GQueue * stack, gboolean res)
 }
 
 static                          gboolean
-process_regexp_expression (struct expression *expr, const gchar *symbol, struct worker_task *task,
+process_regexp_expression (struct expression *expr, const gchar *symbol, struct rspamd_task *task,
                const gchar *additional, struct lua_locked_state *nL)
 {
        GQueue                         *stack;
@@ -1233,7 +1233,7 @@ process_regexp_expression (struct expression *expr, const gchar *symbol, struct
 
 struct regexp_threaded_ud {
        struct regexp_module_item *item;
-       struct worker_task *task;
+       struct rspamd_task *task;
 };
 
 static void
@@ -1252,7 +1252,7 @@ process_regexp_item_threaded (gpointer data, gpointer user_data)
 }
 
 static void
-process_regexp_item (struct worker_task *task, void *user_data)
+process_regexp_item (struct rspamd_task *task, void *user_data)
 {
        struct regexp_module_item      *item = user_data;
        gboolean                        res = FALSE;
@@ -1316,7 +1316,7 @@ process_regexp_item (struct worker_task *task, void *user_data)
 }
 
 static                          gboolean
-rspamd_regexp_match_number (struct worker_task *task, GList * args, void *unused)
+rspamd_regexp_match_number (struct rspamd_task *task, GList * args, void *unused)
 {
        gint                            param_count, res = 0;
        struct expression_argument     *arg;
@@ -1353,7 +1353,7 @@ rspamd_regexp_match_number (struct worker_task *task, GList * args, void *unused
 }
 
 static                          gboolean
-rspamd_regexp_occurs_number (struct worker_task *task, GList * args, void *unused)
+rspamd_regexp_occurs_number (struct rspamd_task *task, GList * args, void *unused)
 {
        gint                            limit;
        struct expression_argument     *arg;
@@ -1420,7 +1420,7 @@ rspamd_regexp_occurs_number (struct worker_task *task, GList * args, void *unuse
        return process_regexp (re, task, NULL, limit, f);
 }
 static                          gboolean
-rspamd_raw_header_exists (struct worker_task *task, GList * args, void *unused)
+rspamd_raw_header_exists (struct rspamd_task *task, GList * args, void *unused)
 {
        struct expression_argument     *arg;
 
@@ -1438,7 +1438,7 @@ rspamd_raw_header_exists (struct worker_task *task, GList * args, void *unused)
 }
 
 static gboolean
-match_smtp_data (struct worker_task *task, const gchar *re_text, const gchar *what)
+match_smtp_data (struct rspamd_task *task, const gchar *re_text, const gchar *what)
 {
        struct rspamd_regexp           *re;
        gint                            r;
@@ -1472,7 +1472,7 @@ match_smtp_data (struct worker_task *task, const gchar *re_text, const gchar *wh
 }
 
 static                          gboolean
-rspamd_check_smtp_data (struct worker_task *task, GList * args, void *unused)
+rspamd_check_smtp_data (struct rspamd_task *task, GList * args, void *unused)
 {
        struct expression_argument     *arg;
        GList                          *cur, *rcpt_list = NULL;
@@ -1595,13 +1595,13 @@ static gint
 lua_regexp_match (lua_State *L)
 {
        void                           *ud = luaL_checkudata (L, 1, "rspamd{task}");
-       struct worker_task             *task;
+       struct rspamd_task             *task;
        const gchar                    *re_text;
        struct rspamd_regexp           *re;
        gint                            r = 0;
 
        luaL_argcheck (L, ud != NULL, 1, "'task' expected");
-       task = ud ? *((struct worker_task **)ud) : NULL;
+       task = ud ? *((struct rspamd_task **)ud) : NULL;
        re_text = luaL_checkstring (L, 2);
 
        /* This is a regexp */
@@ -1622,7 +1622,7 @@ lua_regexp_match (lua_State *L)
 }
 
 static gboolean
-rspamd_content_type_compare_param (struct worker_task * task, GList * args, void *unused)
+rspamd_content_type_compare_param (struct rspamd_task * task, GList * args, void *unused)
 {
        gchar                           *param_name, *param_pattern;
        const gchar                     *param_data;
@@ -1733,7 +1733,7 @@ rspamd_content_type_compare_param (struct worker_task * task, GList * args, void
 }
 
 static gboolean
-rspamd_content_type_has_param (struct worker_task * task, GList * args, void *unused)
+rspamd_content_type_has_param (struct rspamd_task * task, GList * args, void *unused)
 {
        gchar                           *param_name;
        const gchar                     *param_data;
@@ -1805,7 +1805,7 @@ rspamd_content_type_has_param (struct worker_task * task, GList * args, void *un
 }
 
 static gboolean
-rspamd_content_type_is_subtype (struct worker_task *task, GList * args, void *unused)
+rspamd_content_type_is_subtype (struct rspamd_task *task, GList * args, void *unused)
 {
        gchar                          *param_pattern;
        struct rspamd_regexp           *re;
@@ -1902,7 +1902,7 @@ rspamd_content_type_is_subtype (struct worker_task *task, GList * args, void *un
 }
 
 static gboolean
-rspamd_content_type_is_type (struct worker_task * task, GList * args, void *unused)
+rspamd_content_type_is_type (struct rspamd_task * task, GList * args, void *unused)
 {
        gchar                          *param_pattern;
        struct rspamd_regexp           *re;
@@ -2000,7 +2000,7 @@ rspamd_content_type_is_type (struct worker_task * task, GList * args, void *unus
 }
 
 static                   gboolean
-compare_subtype (struct worker_task *task, GMimeContentType * ct, gchar *subtype)
+compare_subtype (struct rspamd_task *task, GMimeContentType * ct, gchar *subtype)
 {
        struct rspamd_regexp           *re;
        gint                            r;
@@ -2059,7 +2059,7 @@ compare_len (struct mime_part *part, guint min, guint max)
 }
 
 static gboolean
-common_has_content_part (struct worker_task * task, gchar *param_type, gchar *param_subtype, gint min_len, gint max_len)
+common_has_content_part (struct rspamd_task * task, gchar *param_type, gchar *param_subtype, gint min_len, gint max_len)
 {
        struct rspamd_regexp           *re;
        struct mime_part               *part;
@@ -2141,7 +2141,7 @@ common_has_content_part (struct worker_task * task, gchar *param_type, gchar *pa
 }
 
 static gboolean
-rspamd_has_content_part (struct worker_task * task, GList * args, void *unused)
+rspamd_has_content_part (struct rspamd_task * task, GList * args, void *unused)
 {
        gchar                           *param_type = NULL, *param_subtype = NULL;
        struct expression_argument     *arg;
@@ -2163,7 +2163,7 @@ rspamd_has_content_part (struct worker_task * task, GList * args, void *unused)
 }
 
 static gboolean
-rspamd_has_content_part_len (struct worker_task * task, GList * args, void *unused)
+rspamd_has_content_part_len (struct rspamd_task * task, GList * args, void *unused)
 {
        gchar                           *param_type = NULL, *param_subtype = NULL;
        gint                            min = 0, max = 0;
index 239e58d3b67c86c4cacf8fa93beaf1d92a8c1891..149e3104d773b38619ff0ec599504ed644262123 100644 (file)
@@ -50,7 +50,7 @@
 #define DEFAULT_CACHE_MAXAGE 86400
 
 struct spf_ctx {
-       gint                            (*filter) (struct worker_task * task);
+       gint                            (*filter) (struct rspamd_task * task);
        const gchar                    *symbol_fail;
        const gchar                    *symbol_softfail;
        const gchar                    *symbol_allow;
@@ -62,7 +62,7 @@ struct spf_ctx {
 
 static struct spf_ctx        *spf_module_ctx = NULL;
 
-static void                   spf_symbol_callback (struct worker_task *task, void *unused);
+static void                   spf_symbol_callback (struct rspamd_task *task, void *unused);
 static GList *                spf_record_copy (GList *addrs);
 static void                   spf_record_destroy (gpointer list);
 
@@ -159,7 +159,7 @@ spf_module_reconfig (struct config_file *cfg)
 }
 
 static gboolean
-spf_check_element (struct spf_addr *addr, struct worker_task *task)
+spf_check_element (struct spf_addr *addr, struct rspamd_task *task)
 {
        gboolean                        res = FALSE;
 #ifdef HAVE_INET_PTON
@@ -252,7 +252,7 @@ spf_check_element (struct spf_addr *addr, struct worker_task *task)
 }
 
 static gboolean
-spf_check_list (GList *list, struct worker_task *task)
+spf_check_list (GList *list, struct rspamd_task *task)
 {
        GList                           *cur;
        struct spf_addr                 *addr;
@@ -279,7 +279,7 @@ spf_check_list (GList *list, struct worker_task *task)
 }
 
 static void 
-spf_plugin_callback (struct spf_record *record, struct worker_task *task)
+spf_plugin_callback (struct spf_record *record, struct rspamd_task *task)
 {
        GList                           *l;
 
@@ -296,7 +296,7 @@ spf_plugin_callback (struct spf_record *record, struct worker_task *task)
 
 
 static void 
-spf_symbol_callback (struct worker_task *task, void *unused)
+spf_symbol_callback (struct rspamd_task *task, void *unused)
 {
        gchar                           *domain;
        GList                           *l;
index 58f9acb580be67a9446a06f6981af2c7b55826e5..3358b65d02864dcb49180574594a5a8ae4266a50 100644 (file)
@@ -56,9 +56,9 @@
 
 static struct surbl_ctx        *surbl_module_ctx = NULL;
 
-static void surbl_test_url (struct worker_task *task, void *user_data);
+static void surbl_test_url (struct rspamd_task *task, void *user_data);
 static void dns_callback (struct rdns_reply *reply, gpointer arg);
-static void process_dns_results (struct worker_task *task,
+static void process_dns_results (struct rspamd_task *task,
                struct suffix_item *suffix, gchar *url, guint32 addr);
 
 
@@ -623,7 +623,7 @@ format_surbl_request (rspamd_mempool_t * pool, f_str_t * hostname, struct suffix
 }
 
 static void
-make_surbl_requests (struct uri *url, struct worker_task *task,
+make_surbl_requests (struct uri *url, struct rspamd_task *task,
                struct suffix_item *suffix, gboolean forced, GTree *tree)
 {
        gchar                           *surbl_req;
@@ -663,7 +663,7 @@ make_surbl_requests (struct uri *url, struct worker_task *task,
 }
 
 static void
-process_dns_results (struct worker_task *task, struct suffix_item *suffix, gchar *url, guint32 addr)
+process_dns_results (struct rspamd_task *task, struct suffix_item *suffix, gchar *url, guint32 addr)
 {
        GList                           *cur;
        struct surbl_bit_item          *bit;
@@ -691,7 +691,7 @@ static void
 dns_callback (struct rdns_reply *reply, gpointer arg)
 {
        struct dns_param               *param = (struct dns_param *)arg;
-       struct worker_task             *task = param->task;
+       struct rspamd_task             *task = param->task;
        struct rdns_reply_entry        *elt;
 
        debug_task ("in surbl request callback");
@@ -759,7 +759,7 @@ memcached_callback (memcached_ctx_t * ctx, memc_error_t error, void *data)
 }
 
 static void
-register_memcached_call (struct uri *url, struct worker_task *task,
+register_memcached_call (struct uri *url, struct rspamd_task *task,
                struct suffix_item *suffix, GTree *tree)
 {
        struct memcached_param         *param;
@@ -825,7 +825,7 @@ static void
 redirector_callback (gint fd, short what, void *arg)
 {
        struct redirector_param        *param = (struct redirector_param *)arg;
-       struct worker_task             *task = param->task;
+       struct rspamd_task             *task = param->task;
        gchar                           url_buf[512];
        gint                            r;
        struct timeval                 *timeout;
@@ -906,7 +906,7 @@ redirector_callback (gint fd, short what, void *arg)
 
 
 static void
-register_redirector_call (struct uri *url, struct worker_task *task,
+register_redirector_call (struct uri *url, struct rspamd_task *task,
                struct suffix_item *suffix, const gchar *rule, GTree *tree)
 {
        gint                            s = -1;
@@ -954,7 +954,7 @@ static                          gboolean
 surbl_tree_url_callback (gpointer key, gpointer value, void *data)
 {
        struct redirector_param        *param = data;
-       struct worker_task             *task;
+       struct rspamd_task             *task;
        struct uri                     *url = value;
        gchar                          *red_domain;
        const gchar                    *pos;
@@ -1008,7 +1008,7 @@ surbl_tree_url_callback (gpointer key, gpointer value, void *data)
 }
 
 static void
-surbl_test_url (struct worker_task *task, void *user_data)
+surbl_test_url (struct rspamd_task *task, void *user_data)
 {
        struct redirector_param         param;
        struct suffix_item             *suffix = user_data;
@@ -1027,7 +1027,7 @@ struct urls_tree_cb_data {
        gchar                          *buf;
        gsize                           len;
        gsize                           off;
-       struct worker_task             *task;
+       struct rspamd_task             *task;
 };
 
 static gboolean
@@ -1069,7 +1069,7 @@ write_urls_buffer (gpointer key, gpointer value, gpointer cbdata)
 
 
 static gboolean
-urls_command_handler (struct worker_task *task)
+urls_command_handler (struct rspamd_task *task)
 {
        struct urls_tree_cb_data        cb;
 
index 80554b713e0719772b182b3c4a2c7b6be84cdd3b..a9b0c194c2c67e301951e73992b6625f3470fab0 100644 (file)
@@ -26,7 +26,7 @@ struct redirector_upstream {
 };
 
 struct surbl_ctx {
-       gint (*filter)(struct worker_task *task);
+       gint (*filter)(struct rspamd_task *task);
        guint16 weight;
        guint connect_timeout;
        guint read_timeout;
@@ -57,14 +57,14 @@ struct suffix_item {
 
 struct dns_param {
        struct uri *url;
-       struct worker_task *task;
+       struct rspamd_task *task;
        gchar *host_resolve;
        struct suffix_item *suffix;
 };
 
 struct redirector_param {
        struct uri *url;
-       struct worker_task *task;
+       struct rspamd_task *task;
        struct redirector_upstream *redirector;
        enum {
                STATE_CONNECT,
@@ -79,7 +79,7 @@ struct redirector_param {
 
 struct memcached_param {
        struct uri *url;
-       struct worker_task *task;
+       struct rspamd_task *task;
        memcached_ctx_t *ctx;
        GTree *tree;
        struct suffix_item *suffix;
index db1fa0bfd63c0cee18cc5a86add5f02b6b34de0a..9da4f445d29ae2ff74f378e8d60ba94b1c86cc47 100644 (file)
@@ -127,7 +127,7 @@ rspamd_protocol_escape_braces (GString *in)
 }
 
 static gboolean
-rspamd_protocol_handle_url (struct worker_task *task, struct rspamd_http_message *msg)
+rspamd_protocol_handle_url (struct rspamd_task *task, struct rspamd_http_message *msg)
 {
        GList                          *cur;
        struct custom_command          *cmd;
@@ -224,7 +224,7 @@ err:
 }
 
 static gboolean
-rspamd_protocol_handle_headers (struct worker_task *task, struct rspamd_http_message *msg)
+rspamd_protocol_handle_headers (struct rspamd_task *task, struct rspamd_http_message *msg)
 {
        gchar                           *headern, *err, *tmp;
        gboolean                         res = TRUE;
@@ -412,7 +412,7 @@ rspamd_protocol_handle_headers (struct worker_task *task, struct rspamd_http_mes
 }
 
 gboolean
-rspamd_protocol_handle_request (struct worker_task *task,
+rspamd_protocol_handle_request (struct rspamd_task *task,
                struct rspamd_http_message *msg)
 {
        gboolean ret = TRUE;
@@ -438,7 +438,7 @@ rspamd_protocol_handle_request (struct worker_task *task,
 }
 
 static void
-write_hashes_to_log (struct worker_task *task, GString *logbuf)
+write_hashes_to_log (struct rspamd_task *task, GString *logbuf)
 {
        GList                          *cur;
        struct mime_text_part          *text_part;
@@ -463,7 +463,7 @@ write_hashes_to_log (struct worker_task *task, GString *logbuf)
 /* Structure for writing tree data */
 struct tree_cb_data {
        ucl_object_t *top;
-       struct worker_task *task;
+       struct rspamd_task *task;
 };
 
 /*
@@ -489,7 +489,7 @@ urls_protocol_cb (gpointer key, gpointer value, gpointer ud)
 }
 
 static ucl_object_t *
-rspamd_urls_tree_ucl (GTree *input, struct worker_task *task)
+rspamd_urls_tree_ucl (GTree *input, struct rspamd_task *task)
 {
        struct tree_cb_data             cb;
        ucl_object_t                    *obj;
@@ -517,7 +517,7 @@ emails_protocol_cb (gpointer key, gpointer value, gpointer ud)
 }
 
 static ucl_object_t *
-rspamd_emails_tree_ucl (GTree *input, struct worker_task *task)
+rspamd_emails_tree_ucl (GTree *input, struct rspamd_task *task)
 {
        struct tree_cb_data             cb;
        ucl_object_t                    *obj;
@@ -534,7 +534,7 @@ rspamd_emails_tree_ucl (GTree *input, struct worker_task *task)
 
 /* Write new subject */
 static const gchar *
-make_rewritten_subject (struct metric *metric, struct worker_task *task)
+make_rewritten_subject (struct metric *metric, struct rspamd_task *task)
 {
        static gchar                    subj_buf[1024];
        gchar                          *p = subj_buf, *end, *c, *res;
@@ -583,7 +583,7 @@ rspamd_str_list_ucl (GList *str_list)
 }
 
 static ucl_object_t *
-rspamd_metric_symbol_ucl (struct worker_task *task, struct metric *m,
+rspamd_metric_symbol_ucl (struct rspamd_task *task, struct metric *m,
                struct symbol *sym, GString *logbuf)
 {
        ucl_object_t                    *obj = NULL;
@@ -606,7 +606,7 @@ rspamd_metric_symbol_ucl (struct worker_task *task, struct metric *m,
 }
 
 static ucl_object_t *
-rspamd_metric_result_ucl (struct worker_task *task, struct metric_result *mres, GString *logbuf)
+rspamd_metric_result_ucl (struct rspamd_task *task, struct metric_result *mres, GString *logbuf)
 {
        GHashTableIter                   hiter;
        struct symbol                  *sym;
@@ -684,7 +684,7 @@ rspamd_metric_result_ucl (struct worker_task *task, struct metric_result *mres,
 }
 
 static void
-rspamd_ucl_tolegacy_output (struct worker_task *task, ucl_object_t *top, GString *out)
+rspamd_ucl_tolegacy_output (struct rspamd_task *task, ucl_object_t *top, GString *out)
 {
        const ucl_object_t *metric, *score,
                *required_score, *is_spam, *elt, *symbols;
@@ -724,7 +724,7 @@ rspamd_ucl_tolegacy_output (struct worker_task *task, ucl_object_t *top, GString
 }
 
 static void
-write_check_reply (struct rspamd_http_message *msg, struct worker_task *task)
+write_check_reply (struct rspamd_http_message *msg, struct rspamd_task *task)
 {
        GString                         *logbuf;
        struct metric_result           *metric_res;
@@ -788,7 +788,7 @@ write_check_reply (struct rspamd_http_message *msg, struct worker_task *task)
 }
 
 void
-rspamd_protocol_write_reply (struct worker_task *task)
+rspamd_protocol_write_reply (struct rspamd_task *task)
 {
        struct rspamd_http_message    *msg;
        const gchar                   *ctype = "application/json";
index 30d3c51dbb65aee90a508e9ac8b1b8539a67213c..912b8744cea11625fc7ecc99e733304d17b83804 100644 (file)
 #define RSPAMD_LENGTH_ERROR RSPAMD_BASE_ERROR + 4
 #define RSPAMD_STATFILE_ERROR RSPAMD_BASE_ERROR + 5
 
-struct worker_task;
+struct rspamd_task;
 struct metric;
 
-
-enum rspamd_command {
-       CMD_CHECK,
-       CMD_SYMBOLS,
-       CMD_REPORT,
-       CMD_REPORT_IFSPAM,
-       CMD_SKIP,
-       CMD_PING,
-       CMD_PROCESS,
-       CMD_OTHER
-};
-
-
-typedef gint (*protocol_reply_func)(struct worker_task *task);
-
-struct custom_command {
-       const gchar *name;
-       protocol_reply_func func;
-};
-
 /**
  * Process HTTP request to the task structure
  * @param task
  * @param msg
  * @return
  */
-gboolean rspamd_protocol_handle_request (struct worker_task *task, struct rspamd_http_message *msg);
+gboolean rspamd_protocol_handle_request (struct rspamd_task *task, struct rspamd_http_message *msg);
 
 /**
  * Write reply for specified task command
  * @param task task object
  * @return 0 if we wrote reply and -1 if there was some error
  */
-void rspamd_protocol_write_reply (struct worker_task *task);
+void rspamd_protocol_write_reply (struct rspamd_task *task);
 
 
 /**
index 1ffa9240faeba5db3bdee6f001ff93dec4e72163..504f8ae3bb353f8bb9b4f5c273cdff7691dab7e8 100644 (file)
@@ -74,7 +74,7 @@ roll_history_symbols_callback (gpointer key, gpointer value, void *user_data)
  * @param task task object
  */
 void
-rspamd_roll_history_update (struct roll_history *history, struct worker_task *task)
+rspamd_roll_history_update (struct roll_history *history, struct rspamd_task *task)
 {
        gint                                                                     row_num;
        struct roll_history_row                                 *row;
index a095843374b1f5f9c0589feec1fec9d3b47458c4..1dff93a4f0a810d49390438c4178d513b14117bf 100644 (file)
@@ -38,7 +38,7 @@
 #define HISTORY_MAX_USER 20
 #define HISTORY_MAX_ROWS 200
 
-struct worker_task;
+struct rspamd_task;
 
 struct roll_history_row {
        struct timeval tv;
@@ -85,7 +85,7 @@ struct roll_history* rspamd_roll_history_new (rspamd_mempool_t *pool);
  * @param history roll history object
  * @param task task object
  */
-void rspamd_roll_history_update (struct roll_history *history, struct worker_task *task);
+void rspamd_roll_history_update (struct roll_history *history, struct rspamd_task *task);
 
 /**
  * Load previously saved history from file
index 2e9b76fd83e6a4e0c006a868d50152a7ebbf4b75..c3292c8ab66c604c2d964e6a44e9a8f77d43a37a 100644 (file)
@@ -381,7 +381,7 @@ init_settings (struct config_file *cfg)
 }
 
 static                          gboolean
-check_setting (struct worker_task *task, struct rspamd_settings **user_settings, struct rspamd_settings **domain_settings)
+check_setting (struct rspamd_task *task, struct rspamd_settings **user_settings, struct rspamd_settings **domain_settings)
 {
        gchar                           *field = NULL, *domain = NULL;
        gchar                            cmp_buf[1024];
@@ -437,7 +437,7 @@ check_setting (struct worker_task *task, struct rspamd_settings **user_settings,
 }
 
 static                         gboolean
-check_bwhitelist (struct worker_task *task, struct rspamd_settings *s, gboolean *is_black)
+check_bwhitelist (struct rspamd_task *task, struct rspamd_settings *s, gboolean *is_black)
 {
        gchar                           *src_email = NULL, *src_domain = NULL, *data;
 
@@ -508,7 +508,7 @@ check_metric_settings (struct metric_result *res, double *score, double *rscore)
 }
 
 gboolean
-check_metric_action_settings (struct worker_task *task, struct metric_result *res,
+check_metric_action_settings (struct rspamd_task *task, struct metric_result *res,
                double score, enum rspamd_metric_action *result)
 {
        struct rspamd_settings         *us = res->user_settings, *ds = res->domain_settings;
@@ -571,7 +571,7 @@ check_metric_action_settings (struct worker_task *task, struct metric_result *re
 }
 
 gboolean
-apply_metric_settings (struct worker_task *task, struct metric *metric, struct metric_result *res)
+apply_metric_settings (struct rspamd_task *task, struct metric *metric, struct metric_result *res)
 {
        struct rspamd_settings         *us = NULL, *ds = NULL;
 
@@ -627,7 +627,7 @@ check_factor_settings (struct metric_result *res, const gchar *symbol, double *f
 
 
 gboolean
-check_want_spam (struct worker_task *task)
+check_want_spam (struct rspamd_task *task)
 {
        struct rspamd_settings         *us = NULL, *ds = NULL;
 
index 7f89dd4b90786d51e87f389a48111d004b82e4cb..3617000943d31ed6e9db53cadd9902518fad3b25 100644 (file)
@@ -35,7 +35,7 @@ gboolean check_metric_settings (struct metric_result *res, double *score, double
 /*
  * Check actions settings
  */
-gboolean check_metric_action_settings (struct worker_task *task, struct metric_result *res, double score, enum rspamd_metric_action *result);
+gboolean check_metric_action_settings (struct rspamd_task *task, struct metric_result *res, double score, enum rspamd_metric_action *result);
 
 /*
  * Check individual weights for settings
@@ -45,11 +45,11 @@ gboolean check_factor_settings (struct metric_result *res, const gchar *symbol,
 /*
  * Check want_spam flag
  */
-gboolean check_want_spam (struct worker_task *task);
+gboolean check_want_spam (struct rspamd_task *task);
 
 /*
  * Search settings for metric and store pointers to settings into metric_result structure
  */
-gboolean apply_metric_settings (struct worker_task *task, struct metric *metric, struct metric_result *res);
+gboolean apply_metric_settings (struct rspamd_task *task, struct metric *metric, struct metric_result *res);
 
 #endif
index ab5bc97663af2294731277eb910d58d11cae24b1..0f47cf0ee1d75d0bf1692a79c71aee72c620e03f 100644 (file)
@@ -73,7 +73,7 @@ struct smtp_session {
        enum rspamd_smtp_state state;
        enum rspamd_smtp_state upstream_state;
        struct rspamd_worker *worker;
-       struct worker_task *task;
+       struct rspamd_task *task;
        struct in_addr client_addr;
        gchar *hostname;
        gchar *error;
index 68aed8e81c062c93c6a15d89c543692b9b3c7cd4..15551aa41361053ddc8f13ed9af6ad59364fb98f 100644 (file)
@@ -141,7 +141,7 @@ smtp_metric_callback (gpointer key, gpointer value, gpointer ud)
        enum rspamd_metric_action       action = METRIC_ACTION_NOACTION;
        double                          ms = 0, rs = 0;
        gboolean                        is_spam = FALSE;
-       struct worker_task             *task;
+       struct rspamd_task             *task;
 
        task = cd->session->task;
 
index ab6102beaca5e50b59b5a075792a8a2ce5d8d5dc..2219a5b8f79a7f5ab43631e52dae645f66308114 100644 (file)
--- a/src/spf.c
+++ b/src/spf.c
@@ -89,7 +89,7 @@ do {                                                                                                          \
        }                                                                                                               \
 } while (0)                                                                                                    \
 
-static gboolean parse_spf_record (struct worker_task *task, struct spf_record *rec);
+static gboolean parse_spf_record (struct rspamd_task *task, struct spf_record *rec);
 static void start_spf_parse (struct spf_record *rec, gchar *begin, guint ttl);
 
 /* Determine spf mech */
@@ -350,7 +350,7 @@ parse_spf_ipmask (const gchar *begin, struct spf_addr *addr, struct spf_record *
 }
 
 static gchar *
-parse_spf_hostmask (struct worker_task *task, const gchar *begin, struct spf_addr *addr, struct spf_record *rec)
+parse_spf_hostmask (struct rspamd_task *task, const gchar *begin, struct spf_addr *addr, struct spf_record *rec)
 {
        gchar                           *host = NULL, *p,  mask_buf[3];
        gint                            hostlen;
@@ -393,7 +393,7 @@ spf_record_dns_callback (struct rdns_reply *reply, gpointer arg)
        gchar                           *begin;
        struct rdns_reply_entry      *elt_data;
        GList                           *tmp = NULL;
-       struct worker_task              *task;
+       struct rspamd_task              *task;
        struct spf_addr                 *new_addr;
 
        task = cb->rec->task;
@@ -600,7 +600,7 @@ spf_record_dns_callback (struct rdns_reply *reply, gpointer arg)
 }
 
 static gboolean
-parse_spf_a (struct worker_task *task, const gchar *begin, struct spf_record *rec, struct spf_addr *addr)
+parse_spf_a (struct rspamd_task *task, const gchar *begin, struct spf_record *rec, struct spf_addr *addr)
 {
        struct spf_dns_cb *cb;
        gchar                           *host;
@@ -635,7 +635,7 @@ parse_spf_a (struct worker_task *task, const gchar *begin, struct spf_record *re
 }
 
 static gboolean
-parse_spf_ptr (struct worker_task *task, const gchar *begin, struct spf_record *rec, struct spf_addr *addr)
+parse_spf_ptr (struct rspamd_task *task, const gchar *begin, struct spf_record *rec, struct spf_addr *addr)
 {
        CHECK_REC (rec);
        
@@ -645,7 +645,7 @@ parse_spf_ptr (struct worker_task *task, const gchar *begin, struct spf_record *
 }
 
 static gboolean
-parse_spf_mx (struct worker_task *task, const gchar *begin, struct spf_record *rec, struct spf_addr *addr)
+parse_spf_mx (struct rspamd_task *task, const gchar *begin, struct spf_record *rec, struct spf_addr *addr)
 {
        struct spf_dns_cb *cb;
        gchar                           *host;
@@ -683,7 +683,7 @@ parse_spf_mx (struct worker_task *task, const gchar *begin, struct spf_record *r
 }
 
 static gboolean
-parse_spf_all (struct worker_task *task, const gchar *begin, struct spf_record *rec, struct spf_addr *addr)
+parse_spf_all (struct rspamd_task *task, const gchar *begin, struct spf_record *rec, struct spf_addr *addr)
 {
        /* All is 0/0 */
        memset (&addr->data.normal.d, 0, sizeof (addr->data.normal.d));
@@ -700,7 +700,7 @@ parse_spf_all (struct worker_task *task, const gchar *begin, struct spf_record *
 }
 
 static gboolean
-parse_spf_ip4 (struct worker_task *task, const gchar *begin, struct spf_record *rec, struct spf_addr *addr)
+parse_spf_ip4 (struct rspamd_task *task, const gchar *begin, struct spf_record *rec, struct spf_addr *addr)
 {
        /* ip4:addr[/mask] */
 
@@ -710,7 +710,7 @@ parse_spf_ip4 (struct worker_task *task, const gchar *begin, struct spf_record *
 
 #ifdef HAVE_INET_PTON
 static gboolean
-parse_spf_ip6 (struct worker_task *task, const gchar *begin, struct spf_record *rec, struct spf_addr *addr)
+parse_spf_ip6 (struct rspamd_task *task, const gchar *begin, struct spf_record *rec, struct spf_addr *addr)
 {
        /* ip6:addr[/mask] */
 
@@ -720,7 +720,7 @@ parse_spf_ip6 (struct worker_task *task, const gchar *begin, struct spf_record *
 #endif
 
 static gboolean
-parse_spf_include (struct worker_task *task, const gchar *begin, struct spf_record *rec, struct spf_addr *addr)
+parse_spf_include (struct rspamd_task *task, const gchar *begin, struct spf_record *rec, struct spf_addr *addr)
 {
        struct spf_dns_cb *cb;
        gchar                           *domain;
@@ -754,7 +754,7 @@ parse_spf_include (struct worker_task *task, const gchar *begin, struct spf_reco
 }
 
 static gboolean
-parse_spf_exp (struct worker_task *task, const gchar *begin, struct spf_record *rec, struct spf_addr *addr)
+parse_spf_exp (struct rspamd_task *task, const gchar *begin, struct spf_record *rec, struct spf_addr *addr)
 {
        CHECK_REC (rec);
 
@@ -763,7 +763,7 @@ parse_spf_exp (struct worker_task *task, const gchar *begin, struct spf_record *
 }
 
 static gboolean
-parse_spf_redirect (struct worker_task *task, const gchar *begin, struct spf_record *rec, struct spf_addr *addr)
+parse_spf_redirect (struct rspamd_task *task, const gchar *begin, struct spf_record *rec, struct spf_addr *addr)
 {
        struct spf_dns_cb *cb;
        gchar                           *domain;
@@ -794,7 +794,7 @@ parse_spf_redirect (struct worker_task *task, const gchar *begin, struct spf_rec
 }
 
 static gboolean
-parse_spf_exists (struct worker_task *task, const gchar *begin, struct spf_record *rec, struct spf_addr *addr)
+parse_spf_exists (struct rspamd_task *task, const gchar *begin, struct spf_record *rec, struct spf_addr *addr)
 {
        struct spf_dns_cb *cb;
        gchar                           *host;
@@ -859,7 +859,7 @@ reverse_spf_ip (gchar *ip, gint len)
 }
 
 static gchar *
-expand_spf_macro (struct worker_task *task, struct spf_record *rec, gchar *begin)
+expand_spf_macro (struct rspamd_task *task, struct spf_record *rec, gchar *begin)
 {
        gchar                           *p, *c, *new, *tmp;
        gint                            len = 0, slen = 0, state = 0;
@@ -1116,7 +1116,7 @@ expand_spf_macro (struct worker_task *task, struct spf_record *rec, gchar *begin
 
 /* Read current element and try to parse record */
 static gboolean
-parse_spf_record (struct worker_task *task, struct spf_record *rec)
+parse_spf_record (struct rspamd_task *task, struct spf_record *rec)
 {
        struct spf_addr *new = NULL;
        gboolean need_shift, res = FALSE;
@@ -1359,7 +1359,7 @@ spf_dns_callback (struct rdns_reply *reply, gpointer arg)
 }
 
 gchar *
-get_spf_domain (struct worker_task *task)
+get_spf_domain (struct rspamd_task *task)
 {
        gchar                           *domain, *res = NULL;
        GList                           *domains;
@@ -1394,7 +1394,7 @@ get_spf_domain (struct worker_task *task)
 }
 
 gboolean
-resolve_spf (struct worker_task *task, spf_cb_t callback)
+resolve_spf (struct rspamd_task *task, spf_cb_t callback)
 {
        struct spf_record               *rec;
        gchar                           *domain;
index 2dd80cc0850ec5ac18a82bfea4896efa9a52cf21..94c613e425e67604ee721b05614e7b3f8df04d19 100644 (file)
--- a/src/spf.h
+++ b/src/spf.h
@@ -3,10 +3,10 @@
 
 #include "config.h"
 
-struct worker_task;
+struct rspamd_task;
 struct spf_record;
 
-typedef void (*spf_cb_t)(struct spf_record *record, struct worker_task *task);
+typedef void (*spf_cb_t)(struct spf_record *record, struct rspamd_task *task);
 
 typedef enum spf_mech_e {
        SPF_FAIL,
@@ -63,7 +63,7 @@ struct spf_record {
        gchar *sender;
        gchar *sender_domain;
        gchar *local_part;
-       struct worker_task *task;
+       struct rspamd_task *task;
        spf_cb_t callback;
 
        gboolean in_include;
@@ -73,12 +73,12 @@ struct spf_record {
 /*
  * Resolve spf record for specified task and call a callback after resolution fails/succeed
  */
-gboolean resolve_spf (struct worker_task *task, spf_cb_t callback);
+gboolean resolve_spf (struct rspamd_task *task, spf_cb_t callback);
 
 /*
  * Get a domain for spf for specified task
  */
-gchar *get_spf_domain (struct worker_task *task);
+gchar *get_spf_domain (struct rspamd_task *task);
 
 
 #endif
index ae9fd605a4e69246321a6a6c3fbe654c526aadb7..042f86998455bcb43ea80d6e2c3e7eb99acb8e1c 100644 (file)
@@ -643,7 +643,7 @@ init_symbols_cache (rspamd_mempool_t * pool, struct symbols_cache *cache, struct
 }
 
 static GList *
-check_dynamic_item (struct worker_task *task, struct symbols_cache *cache)
+check_dynamic_item (struct rspamd_task *task, struct symbols_cache *cache)
 {
 #ifdef HAVE_INET_PTON
        /* TODO: radix doesn't support ipv6 addrs */
@@ -665,7 +665,7 @@ check_dynamic_item (struct worker_task *task, struct symbols_cache *cache)
 }
 
 static gboolean
-check_negative_dynamic_item (struct worker_task *task, struct symbols_cache *cache, struct cache_item *item)
+check_negative_dynamic_item (struct rspamd_task *task, struct symbols_cache *cache, struct cache_item *item)
 {
 
 #ifdef HAVE_INET_PTON
@@ -841,7 +841,7 @@ struct symbol_callback_data {
 };
 
 gboolean
-call_symbol_callback (struct worker_task * task, struct symbols_cache * cache, gpointer *save)
+call_symbol_callback (struct rspamd_task * task, struct symbols_cache * cache, gpointer *save)
 {
 #ifdef HAVE_CLOCK_GETTIME
        struct timespec                 ts1, ts2;
index cbbc9e8fff9b2d418a6b7316bbba1b2c4527f7c6..bb2100fc1c40d5db41cca9f2a08144c96feb7403 100644 (file)
@@ -6,10 +6,10 @@
 
 #define MAX_SYMBOL 128
 
-struct worker_task;
+struct rspamd_task;
 struct config_file;
 
-typedef void (*symbol_func_t)(struct worker_task *task, gpointer user_data);
+typedef void (*symbol_func_t)(struct rspamd_task *task, gpointer user_data);
 
 struct saved_cache_item {
        gchar symbol[MAX_SYMBOL];
@@ -130,7 +130,7 @@ void register_dynamic_symbol (rspamd_mempool_t *pool, struct symbols_cache **cac
  * @param cache symbols cache
  * @param saved_item pointer to currently saved item
  */
-gboolean call_symbol_callback (struct worker_task *task, struct symbols_cache *cache, gpointer *save);
+gboolean call_symbol_callback (struct rspamd_task *task, struct symbols_cache *cache, gpointer *save);
 
 /**
  * Remove all dynamic rules from cache
diff --git a/src/task.c b/src/task.c
new file mode 100644 (file)
index 0000000..126ddcd
--- /dev/null
@@ -0,0 +1,23 @@
+/* Copyright (c) 2014, Vsevolod Stakhov
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *       * Redistributions of source code must retain the above copyright
+ *         notice, this list of conditions and the following disclaimer.
+ *       * Redistributions in binary form must reproduce the above copyright
+ *         notice, this list of conditions and the following disclaimer in the
+ *         documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
diff --git a/src/task.h b/src/task.h
new file mode 100644 (file)
index 0000000..21948e1
--- /dev/null
@@ -0,0 +1,147 @@
+/* Copyright (c) 2014, Vsevolod Stakhov
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *       * Redistributions of source code must retain the above copyright
+ *         notice, this list of conditions and the following disclaimer.
+ *       * Redistributions in binary form must reproduce the above copyright
+ *         notice, this list of conditions and the following disclaimer in the
+ *         documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef TASK_H_
+#define TASK_H_
+
+#include "config.h"
+#include "http.h"
+#include "events.h"
+#include "util.h"
+#include "mem_pool.h"
+#include "dns.h"
+
+enum rspamd_command {
+       CMD_CHECK,
+       CMD_SYMBOLS,
+       CMD_REPORT,
+       CMD_REPORT_IFSPAM,
+       CMD_SKIP,
+       CMD_PING,
+       CMD_PROCESS,
+       CMD_OTHER
+};
+
+enum rspamd_metric_action {
+       METRIC_ACTION_REJECT = 0,
+       METRIC_ACTION_SOFT_REJECT,
+       METRIC_ACTION_REWRITE_SUBJECT,
+       METRIC_ACTION_ADD_HEADER,
+       METRIC_ACTION_GREYLIST,
+       METRIC_ACTION_NOACTION,
+       METRIC_ACTION_MAX
+};
+
+typedef gint (*protocol_reply_func)(struct rspamd_task *task);
+
+struct custom_command {
+       const gchar *name;
+       protocol_reply_func func;
+};
+
+struct rspamd_view;
+
+/**
+ * Worker task structure
+ */
+struct rspamd_task {
+       struct rspamd_worker *worker;                                                           /**< pointer to worker object                                           */
+       enum {
+               READ_MESSAGE,
+               WAIT_PRE_FILTER,
+               WAIT_FILTER,
+               WAIT_POST_FILTER,
+               WRITE_REPLY,
+               CLOSING_CONNECTION
+       } state;                                                                                                        /**< current session state                                                      */
+       enum rspamd_command cmd;                                                                        /**< command                                                                            */
+       struct custom_command *custom_cmd;                                                      /**< custom command if any                                                      */
+       gint sock;                                                                                                      /**< socket descriptor                                                          */
+       gboolean is_mime;                                           /**< if this task is mime task                      */
+       gboolean is_json;                                                                                       /**< output is JSON                                                                     */
+       gboolean allow_learn;                                                                           /**< allow learning                                                                     */
+       gboolean is_skipped;                                        /**< whether message was skipped by configuration   */
+
+       gchar *helo;                                                                                                    /**< helo header value                                                          */
+       gchar *from;                                                                                                    /**< from header value                                                          */
+       gchar *queue_id;                                                                                                /**< queue id if specified                                                      */
+       const gchar *message_id;                                                                                /**< message id                                                                         */
+       GList *rcpt;                                                                                                    /**< recipients list                                                            */
+       guint nrcpt;                                                                                    /**< number of recipients                                                       */
+       rspamd_inet_addr_t from_addr;                                                           /**< from addr for a task                                                       */
+       rspamd_inet_addr_t client_addr;                                                         /**< address of connected socket                                        */
+       gchar *deliver_to;                                                                                      /**< address to deliver                                                         */
+       gchar *user;                                                                                                    /**< user to deliver                                                            */
+       gchar *subject;                                                                                         /**< subject (for non-mime)                                                     */
+       gchar *hostname;                                                                                        /**< hostname reported by MTA                                           */
+       GString *msg;                                                                                           /**< message buffer                                                                     */
+       struct rspamd_http_connection *http_conn;                                       /**< HTTP server connection                                                     */
+       struct rspamd_async_session* s;                                                         /**< async session object                                                       */
+       gint parts_count;                                                                                       /**< mime parts count                                                           */
+       GMimeMessage *message;                                                                          /**< message, parsed with GMime                                         */
+       GMimeObject *parser_parent_part;                                                        /**< current parent part                                                        */
+       InternetAddressList *rcpts;                                                                     /**< list of all recipients                                             */
+       GList *parts;                                                                                           /**< list of parsed parts                                                       */
+       GList *text_parts;                                                                                      /**< list of text parts                                                         */
+       gchar *raw_headers_str;                                                                                 /**< list of raw headers                                                        */
+       GList *received;                                                                                        /**< list of received headers                                           */
+       GTree *urls;                                                                                            /**< list of parsed urls                                                        */
+       GTree *emails;                                                                                          /**< list of parsed emails                                                      */
+       GList *images;                                                                                          /**< list of images                                                                     */
+       GHashTable *raw_headers;                                                                        /**< list of raw headers                                                        */
+       GHashTable *results;                                                                            /**< hash table of metric_result indexed by
+        *    metric's name                                                                     */
+       GHashTable *tokens;                                                                                     /**< hash table of tokens indexed by tokenizer
+        *    pointer                                                                           */
+       GList *messages;                                                                                        /**< list of messages that would be reported            */
+       GHashTable *re_cache;                                                                           /**< cache for matched or not matched regexps           */
+       struct config_file *cfg;                                                                        /**< pointer to config object                                           */
+       gchar *last_error;                                                                                      /**< last error                                                                         */
+       gint error_code;                                                                                                /**< code of last error                                                         */
+       rspamd_mempool_t *task_pool;                                                                    /**< memory pool for task                                                       */
+#ifdef HAVE_CLOCK_GETTIME
+       struct timespec ts;                                                                                     /**< time of connection                                                         */
+#endif
+       struct timeval tv;                                                                                      /**< time of connection                                                         */
+       struct rspamd_view *view;                                                                       /**< matching view                                                                      */
+       guint32 scan_milliseconds;                                                                      /**< how much milliseconds passed                                       */
+       gboolean view_checked;
+       gboolean pass_all_filters;                                                                      /**< pass task throught every rule                                      */
+       gboolean no_log;                                                                                        /**< do not log or write this task to the history       */
+       guint32 parser_recursion;                                                                       /**< for avoiding recursion stack overflow                      */
+       gboolean (*fin_callback)(void *arg);                                            /**< calback for filters finalizing                                     */
+       void *fin_arg;                                                                                          /**< argument for fin callback                                          */
+
+       guint32 dns_requests;                                                                           /**< number of DNS requests per this task                       */
+
+       struct rspamd_dns_resolver *resolver;                                           /**< DNS resolver                                                                       */
+       struct event_base *ev_base;                                                                     /**< Event base                                                                         */
+
+       GThreadPool *classify_pool;                                                                     /**< A pool of classify threads                                         */
+
+       struct {
+               enum rspamd_metric_action action;                                               /**< Action of pre filters                                                      */
+               gchar *str;                                                                                             /**< String describing action                                           */
+       } pre_result;                                                                                           /**< Result of pre-filters                                                      */
+};
+
+#endif /* TASK_H_ */
index 0cdd0aaf4cc8e64d80eb85389b53751698ebecaf..448dcd53ebfd87e8e8885b360fee2cc39bdc072e 100644 (file)
@@ -189,7 +189,7 @@ typedef struct _GMimeHeader {
 } local_GMimeHeader;
 
 int
-tokenize_headers (rspamd_mempool_t * pool, struct worker_task *task, GTree ** tree)
+tokenize_headers (rspamd_mempool_t * pool, struct rspamd_task *task, GTree ** tree)
 {
        token_node_t                   *new = NULL;
        f_str_t                         headername;
@@ -252,7 +252,7 @@ tokenize_headers (rspamd_mempool_t * pool, struct worker_task *task, GTree ** tr
 }
 
 void
-tokenize_subject (struct worker_task *task, GTree ** tree)
+tokenize_subject (struct rspamd_task *task, GTree ** tree)
 {
        f_str_t                         subject;
        const gchar                    *sub;
index 0a8d27d57113327d302d2a2dd5c483e3c864d282..207602dc8789e08c9df8cc6fa50be5ed0ded5652 100644 (file)
@@ -34,9 +34,9 @@ gchar* get_next_word (f_str_t *buf, f_str_t *token, GList **exceptions);
 int osb_tokenize_text (struct tokenizer *tokenizer, rspamd_mempool_t *pool, f_str_t *input,
                GTree **cur, gboolean save_token, gboolean is_utf, GList *exceptions);
 /* Common tokenizer for headers */
-int tokenize_headers (rspamd_mempool_t *pool, struct worker_task *task, GTree **cur);
+int tokenize_headers (rspamd_mempool_t *pool, struct rspamd_task *task, GTree **cur);
 /* Make tokens for a subject */
-void tokenize_subject (struct worker_task *task, GTree ** tree);
+void tokenize_subject (struct rspamd_task *task, GTree ** tree);
 
 /* Array of all defined tokenizers */
 extern struct tokenizer tokenizers[];
index fa239b5ff644797f1c6f05fd736e1033dfa7fdf0..c4313e8a9166566512c5f9abe2e17d75e69acb63 100644 (file)
--- a/src/url.c
+++ b/src/url.c
@@ -1488,7 +1488,7 @@ url_email_end (const gchar *begin, const gchar *end, const gchar *pos, url_match
 }
 
 void
-url_parse_text (rspamd_mempool_t * pool, struct worker_task *task, struct mime_text_part *part, gboolean is_html)
+url_parse_text (rspamd_mempool_t * pool, struct rspamd_task *task, struct mime_text_part *part, gboolean is_html)
 {
        gint                            rc;
        gchar                          *url_str = NULL, *url_start, *url_end;
index 224bece6b091c37829ba7aaedcf49fc5c83b3bdb..60535ba5c72b0b160cef3d7f1ca644344cc5b12e 100644 (file)
--- a/src/url.h
+++ b/src/url.h
@@ -5,7 +5,7 @@
 #include "config.h"
 #include "mem_pool.h"
 
-struct worker_task;
+struct rspamd_task;
 struct mime_text_part;
 
 struct uri {
@@ -81,7 +81,7 @@ enum protocol {
  * @param part current text part
  * @param is_html turn on html euristic
  */
-void url_parse_text (rspamd_mempool_t *pool, struct worker_task *task, struct mime_text_part *part, gboolean is_html);
+void url_parse_text (rspamd_mempool_t *pool, struct rspamd_task *task, struct mime_text_part *part, gboolean is_html);
 
 /*
  * Parse a single url into an uri structure
index 643c8ef38ff154bc56e3c65d8cb30555344b428a..972730d04940af9b35284fa052dfe93de4848bc2 100644 (file)
@@ -26,6 +26,13 @@ union sa_union {
        struct sockaddr_un su;
 };
 
+typedef struct _rspamd_inet_addr_s {
+       union sa_union addr;
+       socklen_t slen;
+       int af;
+} rspamd_inet_addr_t;
+
+
 /*
  * Create socket and bind or connect it to specified address and port
  */
@@ -454,4 +461,5 @@ gboolean rspamd_ip_is_valid (void *ptr, int af);
  */
 void rspamd_ucl_emit_gstring (ucl_object_t *obj, enum ucl_emitter emit_type, GString *target);
 
+
 #endif
index 7ff7968bcc12c70b0f9387fa734312c0c1731763..f3534f84c3703025ac01f4fb1579c90d84f66548 100644 (file)
@@ -131,7 +131,7 @@ add_view_client_ip (struct rspamd_view * view, const gchar *line)
 
 
 static struct rspamd_view             *
-find_view_by_ip (GList * views, struct worker_task *task)
+find_view_by_ip (GList * views, struct rspamd_task *task)
 {
        GList                          *cur;
        struct rspamd_view             *v;
@@ -172,7 +172,7 @@ find_view_by_ip (GList * views, struct worker_task *task)
 }
 
 static struct rspamd_view             *
-find_view_by_client_ip (GList * views, struct worker_task *task)
+find_view_by_client_ip (GList * views, struct rspamd_task *task)
 {
        GList                          *cur;
        struct rspamd_view             *v;
@@ -195,7 +195,7 @@ find_view_by_client_ip (GList * views, struct worker_task *task)
 }
 
 static struct rspamd_view             *
-find_view_by_from (GList * views, struct worker_task *task)
+find_view_by_from (GList * views, struct rspamd_task *task)
 {
        GList                          *cur, *cur_re;
        struct rspamd_view             *v;
@@ -239,7 +239,7 @@ find_view_by_from (GList * views, struct worker_task *task)
 }
 
 static inline gboolean
-check_view_rcpt (struct rspamd_view *v, struct worker_task *task)
+check_view_rcpt (struct rspamd_view *v, struct rspamd_task *task)
 {
        GList                          *cur, *cur_re;
        gchar                           rcpt_user[256], *p;
@@ -292,7 +292,7 @@ check_view_rcpt (struct rspamd_view *v, struct worker_task *task)
 }
 
 static struct rspamd_view             *
-find_view_by_rcpt (GList * views, struct worker_task *task)
+find_view_by_rcpt (GList * views, struct rspamd_task *task)
 {
        GList                          *cur;
        struct rspamd_view             *v;
@@ -342,7 +342,7 @@ match_view_symbol (struct rspamd_view *v, const gchar *symbol)
 }
 
 gboolean
-check_view (GList * views, const gchar *symbol, struct worker_task * task)
+check_view (GList * views, const gchar *symbol, struct rspamd_task * task)
 {
        struct rspamd_view             *selected = NULL;
 
@@ -384,7 +384,7 @@ check_view (GList * views, const gchar *symbol, struct worker_task * task)
 }
 
 gboolean
-check_skip (GList * views, struct worker_task * task)
+check_skip (GList * views, struct rspamd_task * task)
 {
        if (check_view (views, NULL, task) == FALSE) {
                return TRUE;
index cb6fc65056355743b2bcd3cecfe3cc67473f4936..ecefa83cb676978c35bdb24d5f275f89e18df40f 100644 (file)
@@ -82,7 +82,7 @@ gboolean add_view_symbols (struct rspamd_view *view, const gchar *line);
  * @param task task object
  * @return whether to check this symbol for this task
  */
-gboolean check_view (GList *views, const gchar *symbol, struct worker_task *task);
+gboolean check_view (GList *views, const gchar *symbol, struct rspamd_task *task);
 
 /**
  * Check whether this task should be skipped from checks
@@ -90,6 +90,6 @@ gboolean check_view (GList *views, const gchar *symbol, struct worker_task *task
  * @param task task object
  * @return
  */
-gboolean check_skip (GList *views, struct worker_task *task);
+gboolean check_skip (GList *views, struct rspamd_task *task);
 
 #endif
index b0b44e5f4c61e88c91077c4c0b6515d22ea4e68d..5e8c33a35d71ccab7cc8868639afa155216742f0 100644 (file)
@@ -120,7 +120,7 @@ struct rspamd_webui_worker_ctx {
 struct rspamd_webui_session {
        struct rspamd_webui_worker_ctx *ctx;
        rspamd_mempool_t *pool;
-       struct worker_task *task;
+       struct rspamd_task *task;
        struct classifier_config *cl;
        struct {
                union {
@@ -284,7 +284,7 @@ rspamd_webui_check_password (struct rspamd_http_connection_entry *entry,
 }
 
 struct scan_callback_data {
-       struct worker_task *task;
+       struct rspamd_task *task;
        struct evhttp_request *req;
        struct rspamd_webui_worker_ctx *ctx;
        gboolean processed;
@@ -434,7 +434,7 @@ rspamd_webui_scan_task_restore (gpointer arg)
 static struct scan_callback_data*
 rspamd_webui_prepare_scan (struct evhttp_request *req, struct rspamd_webui_worker_ctx *ctx, struct evbuffer *in, GError **err)
 {
-       struct worker_task                                              *task;
+       struct rspamd_task                                              *task;
        struct scan_callback_data                               *cbdata;
 
        /* Check for data */
@@ -483,7 +483,7 @@ rspamd_webui_prepare_scan (struct evhttp_request *req, struct rspamd_webui_worke
 }
 
 struct learn_callback_data {
-       struct worker_task *task;
+       struct rspamd_task *task;
        struct evhttp_request *req;
        struct classifier_config *classifier;
        struct rspamd_webui_worker_ctx *ctx;
@@ -593,7 +593,7 @@ rspamd_webui_learn_task_restore (gpointer arg)
 static struct learn_callback_data*
 rspamd_webui_prepare_learn (struct evhttp_request *req, struct rspamd_webui_worker_ctx *ctx, struct evbuffer *in, gboolean is_spam, GError **err)
 {
-       struct worker_task                                              *task;
+       struct rspamd_task                                              *task;
        struct learn_callback_data                              *cbdata;
        struct classifier_config                                *cl;
 
@@ -1221,7 +1221,7 @@ rspamd_webui_handle_history (struct rspamd_http_connection_entry *conn_ent,
 static gboolean
 rspamd_webui_learn_fin_task (void *ud)
 {
-       struct worker_task                                              *task = ud;
+       struct rspamd_task                                              *task = ud;
        struct rspamd_webui_session                     *session;
        struct rspamd_http_connection_entry             *conn_ent;
        GError                                                                  *err = NULL;
@@ -1246,7 +1246,7 @@ rspamd_webui_handle_learn_common (struct rspamd_http_connection_entry *conn_ent,
        struct rspamd_webui_session                     *session = conn_ent->ud;
        struct rspamd_webui_worker_ctx                  *ctx;
        struct classifier_config                                *cl;
-       struct worker_task                                              *task;
+       struct rspamd_task                                              *task;
        const gchar                                                             *classifier;
 
        ctx = session->ctx;
index 8f676635045835d469ae6c81d1666b70000cd1d5..b67b02775e47dfa4dacc1f18734d11c838e43b29 100644 (file)
@@ -168,7 +168,7 @@ rspamd_worker_body_handler (struct rspamd_http_connection *conn,
                struct rspamd_http_message *msg,
                const gchar *chunk, gsize len)
 {
-       struct worker_task             *task = (struct worker_task *) conn->ud;
+       struct rspamd_task             *task = (struct rspamd_task *) conn->ud;
        struct rspamd_worker_ctx       *ctx;
        ssize_t                         r;
        GError                         *err = NULL;
@@ -251,7 +251,7 @@ rspamd_worker_body_handler (struct rspamd_http_connection *conn,
 static void
 rspamd_worker_error_handler (struct rspamd_http_connection *conn, GError *err)
 {
-       struct worker_task             *task = (struct worker_task *) conn->ud;
+       struct rspamd_task             *task = (struct rspamd_task *) conn->ud;
 
        msg_info ("abnormally closing connection from: %s, error: %s",
                        inet_ntoa (task->client_addr), err->message);
@@ -272,7 +272,7 @@ static gint
 rspamd_worker_finish_handler (struct rspamd_http_connection *conn,
                struct rspamd_http_message *msg)
 {
-       struct worker_task             *task = (struct worker_task *) conn->ud;
+       struct rspamd_task             *task = (struct rspamd_task *) conn->ud;
 
        if (task->state == CLOSING_CONNECTION) {
                msg_debug ("normally closing connection from: %s", inet_ntoa (task->client_addr));
@@ -299,7 +299,7 @@ accept_socket (gint fd, short what, void *arg)
        struct rspamd_worker           *worker = (struct rspamd_worker *) arg;
        struct rspamd_worker_ctx       *ctx;
        union sa_union                  su;
-       struct worker_task             *new_task;
+       struct rspamd_task             *new_task;
        char                            ip_str[INET6_ADDRSTRLEN + 1];
 
        socklen_t                       addrlen = sizeof (su);
index 9d86e8d3bfda5d830783bfdca652a337f4f514ac..99bad83fd6c7358fc74a1e7851fa12a5cf99ef25 100644 (file)
@@ -34,7 +34,7 @@ extern struct rspamd_main                     *rspamd_main;
 static void
 rcpt_destruct (void *pointer)
 {
-       struct worker_task             *task = (struct worker_task *) pointer;
+       struct rspamd_task             *task = (struct rspamd_task *) pointer;
 
        if (task->rcpt) {
                g_list_free (task->rcpt);
@@ -44,12 +44,12 @@ rcpt_destruct (void *pointer)
 /*
  * Create new task
  */
-struct worker_task             *
+struct rspamd_task             *
 construct_task (struct rspamd_worker *worker)
 {
-       struct worker_task             *new_task;
+       struct rspamd_task             *new_task;
 
-       new_task = g_slice_alloc0 (sizeof (struct worker_task));
+       new_task = g_slice_alloc0 (sizeof (struct rspamd_task));
 
        new_task->worker = worker;
        new_task->state = READ_MESSAGE;
@@ -130,7 +130,7 @@ get_worker_by_type (GQuark type)
  * Free all structures of worker_task
  */
 void
-free_task (struct worker_task *task, gboolean is_soft)
+free_task (struct rspamd_task *task, gboolean is_soft)
 {
        GList                          *part;
        struct mime_part               *p;
@@ -171,14 +171,14 @@ free_task (struct worker_task *task, gboolean is_soft)
                        close (task->sock);
                }
                rspamd_mempool_delete (task->task_pool);
-               g_slice_free1 (sizeof (struct worker_task), task);
+               g_slice_free1 (sizeof (struct rspamd_task), task);
        }
 }
 
 void
 free_task_hard (gpointer ud)
 {
-  struct worker_task             *task = ud;
+  struct rspamd_task             *task = ud;
 
   free_task (task, FALSE);
 }
@@ -186,7 +186,7 @@ free_task_hard (gpointer ud)
 void
 free_task_soft (gpointer ud)
 {
-  struct worker_task             *task = ud;
+  struct rspamd_task             *task = ud;
 
   free_task (task, FALSE);
 }
@@ -290,7 +290,7 @@ worker_stop_accept (struct rspamd_worker *worker)
 gboolean
 rspamd_fin_task (void *arg)
 {
-       struct worker_task              *task = (struct worker_task *) arg;
+       struct rspamd_task              *task = (struct rspamd_task *) arg;
        gint r;
        GError *err = NULL;
 
@@ -387,7 +387,7 @@ rspamd_fin_task (void *arg)
 void
 rspamd_restore_task (void *arg)
 {
-       struct worker_task             *task = (struct worker_task *) arg;
+       struct rspamd_task             *task = (struct rspamd_task *) arg;
 
        /* Call post filters */
        if (task->state == WAIT_POST_FILTER) {