diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-10-26 16:06:12 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-10-26 16:06:12 +0100 |
commit | 0c20729f33f07cdcef5f7c10bde04f262c4a4574 (patch) | |
tree | 66853c7d49a7e51715ce1bc73ab12998bc28c7a9 /src/plugins | |
parent | 2ae394086bb5385ae4bc216cf694fe35692522a3 (diff) | |
download | rspamd-0c20729f33f07cdcef5f7c10bde04f262c4a4574.tar.gz rspamd-0c20729f33f07cdcef5f7c10bde04f262c4a4574.zip |
[Rework] Add more traces to async events, get rid of GQuarks
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/dkim_check.c | 6 | ||||
-rw-r--r-- | src/plugins/fuzzy_check.c | 26 | ||||
-rw-r--r-- | src/plugins/spf.c | 10 | ||||
-rw-r--r-- | src/plugins/surbl.c | 28 |
4 files changed, 38 insertions, 32 deletions
diff --git a/src/plugins/dkim_check.c b/src/plugins/dkim_check.c index f1a67085e..ae4b0f04d 100644 --- a/src/plugins/dkim_check.c +++ b/src/plugins/dkim_check.c @@ -50,6 +50,8 @@ #define DEFAULT_TIME_JITTER 60 #define DEFAULT_MAX_SIGS 5 +static const gchar *M = "rspamd dkim plugin"; + static const gchar default_sign_headers[] = "" "(o)from:(o)sender:(o)reply-to:(o)subject:(o)date:(o)message-id:" "(o)to:(o)cc:(o)mime-version:(o)content-type:(o)content-transfer-encoding:" @@ -1130,7 +1132,7 @@ dkim_symbol_callback (struct rspamd_task *task, return; } - rspamd_symcache_item_async_inc (task, item); + rspamd_symcache_item_async_inc (task, item, M); /* Now check if a message has its signature */ hlist = rspamd_message_get_header_array (task, @@ -1239,7 +1241,7 @@ dkim_symbol_callback (struct rspamd_task *task, dkim_module_check (res); } - rspamd_symcache_item_async_dec_check (task, item); + rspamd_symcache_item_async_dec_check (task, item, M); } static void diff --git a/src/plugins/fuzzy_check.c b/src/plugins/fuzzy_check.c index 3da793adc..e61fa7ce3 100644 --- a/src/plugins/fuzzy_check.c +++ b/src/plugins/fuzzy_check.c @@ -58,6 +58,7 @@ #define RSPAMD_FUZZY_PLUGIN_VERSION RSPAMD_FUZZY_VERSION static const gint rspamd_fuzzy_hash_len = 5; +static const gchar *M = "fuzzy check"; struct fuzzy_ctx; struct fuzzy_mapping { @@ -2108,7 +2109,7 @@ fuzzy_check_session_is_completed (struct fuzzy_client_session *session) if (nreplied == session->commands->len) { fuzzy_insert_metric_results (session->task, session->results); if (session->item) { - rspamd_symcache_item_async_dec_check (session->task, session->item); + rspamd_symcache_item_async_dec_check (session->task, session->item, M); } rspamd_session_remove_event (session->task->s, fuzzy_io_fin, session); @@ -2186,7 +2187,7 @@ fuzzy_check_io_callback (gint fd, short what, void *arg) rspamd_upstream_fail (session->server, FALSE); if (session->item) { - rspamd_symcache_item_async_dec_check (session->task, session->item); + rspamd_symcache_item_async_dec_check (session->task, session->item, M); } rspamd_session_remove_event (session->task->s, fuzzy_io_fin, session); } @@ -2229,7 +2230,7 @@ fuzzy_check_timer_callback (gint fd, short what, void *arg) session->retransmits); rspamd_upstream_fail (session->server, FALSE); if (session->item) { - rspamd_symcache_item_async_dec_check (session->task, session->item); + rspamd_symcache_item_async_dec_check (session->task, session->item, M); } rspamd_session_remove_event (session->task->s, fuzzy_io_fin, session); } @@ -2298,7 +2299,7 @@ fuzzy_controller_io_callback (gint fd, short what, void *arg) session->task->message_id, strerror (errno)); if (*(session->err) == NULL) { g_set_error (session->err, - g_quark_from_static_string ("fuzzy check"), + g_quark_from_static_string (M), errno, "read socket error: %s", strerror (errno)); } ret = return_error; @@ -2362,7 +2363,7 @@ fuzzy_controller_io_callback (gint fd, short what, void *arg) if (*(session->err) == NULL) { g_set_error (session->err, - g_quark_from_static_string ("fuzzy check"), + g_quark_from_static_string (M), rep->v1.value, "fuzzy hash is skipped"); } } @@ -2381,7 +2382,7 @@ fuzzy_controller_io_callback (gint fd, short what, void *arg) if (*(session->err) == NULL) { g_set_error (session->err, - g_quark_from_static_string ("fuzzy check"), + g_quark_from_static_string (M), rep->v1.value, "process fuzzy error"); } } @@ -2410,7 +2411,7 @@ fuzzy_controller_io_callback (gint fd, short what, void *arg) if (!fuzzy_cmd_vector_to_wire (fd, session->commands)) { if (*(session->err) == NULL) { g_set_error (session->err, - g_quark_from_static_string ("fuzzy check"), + g_quark_from_static_string (M), errno, "write socket error: %s", strerror (errno)); } ret = return_error; @@ -2883,12 +2884,11 @@ register_fuzzy_client_call (struct rspamd_task *task, event_base_set (session->task->ev_base, &session->timev); event_add (&session->timev, &session->tv); - rspamd_session_add_event (task->s, fuzzy_io_fin, session, - g_quark_from_static_string ("fuzzy check")); + rspamd_session_add_event (task->s, fuzzy_io_fin, session, M); session->item = rspamd_symbols_cache_get_cur_item (task); if (session->item) { - rspamd_symcache_item_async_inc (task, session->item); + rspamd_symcache_item_async_inc (task, session->item, M); } } } @@ -2925,7 +2925,7 @@ fuzzy_symbol_callback (struct rspamd_task *task, } } - rspamd_symcache_item_async_inc (task, item); + rspamd_symcache_item_async_inc (task, item, M); PTR_ARRAY_FOREACH (fuzzy_module_ctx->fuzzy_rules, i, rule) { commands = fuzzy_generate_commands (task, rule, FUZZY_CHECK, 0, 0, 0); @@ -2935,7 +2935,7 @@ fuzzy_symbol_callback (struct rspamd_task *task, } } - rspamd_symcache_item_async_dec_check (task, item); + rspamd_symcache_item_async_dec_check (task, item, M); } void @@ -3374,7 +3374,7 @@ fuzzy_check_send_lua_learn (struct fuzzy_rule *rule, rspamd_session_add_event (task->s, fuzzy_lua_fin, s, - g_quark_from_static_string ("fuzzy check")); + M); (*saved)++; ret = 1; diff --git a/src/plugins/spf.c b/src/plugins/spf.c index c3337a4eb..271fd1892 100644 --- a/src/plugins/spf.c +++ b/src/plugins/spf.c @@ -45,6 +45,8 @@ #define DEFAULT_SYMBOL_NA "R_SPF_NA" #define DEFAULT_CACHE_SIZE 2048 +static const gchar *M = "rspamd spf plugin"; + struct spf_ctx { struct module_ctx ctx; const gchar *symbol_fail; @@ -562,7 +564,7 @@ spf_plugin_callback (struct spf_resolved *record, struct rspamd_task *task, spf_record_unref (l); } - rspamd_symcache_item_async_dec_check (task, item); + rspamd_symcache_item_async_dec_check (task, item, M); } @@ -608,7 +610,7 @@ spf_symbol_callback (struct rspamd_task *task, } domain = rspamd_spf_get_domain (task); - rspamd_symcache_item_async_inc (task, item); + rspamd_symcache_item_async_inc (task, item, M); if (domain) { if ((l = @@ -629,10 +631,10 @@ spf_symbol_callback (struct rspamd_task *task, "(SPF): spf DNS fail"); } else { - rspamd_symcache_item_async_inc (task, item); + rspamd_symcache_item_async_inc (task, item, M); } } } - rspamd_symcache_item_async_dec_check (task, item); + rspamd_symcache_item_async_dec_check (task, item, M); } diff --git a/src/plugins/surbl.c b/src/plugins/surbl.c index 8070bfb23..4c3fbefa1 100644 --- a/src/plugins/surbl.c +++ b/src/plugins/surbl.c @@ -64,6 +64,8 @@ INIT_LOG_MODULE(surbl) +static const gchar *M = "surbl"; + #define DEFAULT_SURBL_WEIGHT 10 #define DEFAULT_REDIRECTOR_READ_TIMEOUT 5.0 #define DEFAULT_SURBL_SYMBOL "SURBL_DNS" @@ -1381,7 +1383,7 @@ make_surbl_requests (struct rspamd_url *url, struct rspamd_task *task, surbl_dns_ip_callback, (void *) param, RDNS_REQUEST_A, surbl_req)) { param->item = item; - rspamd_symcache_item_async_inc (task, item); + rspamd_symcache_item_async_inc (task, item, M); } } } @@ -1408,7 +1410,7 @@ make_surbl_requests (struct rspamd_url *url, struct rspamd_task *task, surbl_dns_callback, (void *) param, RDNS_REQUEST_A, surbl_req)) { param->item = item; - rspamd_symcache_item_async_inc (task, item); + rspamd_symcache_item_async_inc (task, item, M); } } else if (err != NULL) { @@ -1513,7 +1515,7 @@ surbl_dns_callback (struct rdns_reply *reply, gpointer arg) param->suffix->suffix); } - rspamd_symcache_item_async_dec_check (param->task, param->item); + rspamd_symcache_item_async_dec_check (param->task, param->item, M); } static void @@ -1552,7 +1554,7 @@ surbl_dns_ip_callback (struct rdns_reply *reply, gpointer arg) if (make_dns_request_task (task, surbl_dns_callback, param, RDNS_REQUEST_A, to_resolve->str)) { - rspamd_symcache_item_async_inc (param->task, param->item); + rspamd_symcache_item_async_inc (param->task, param->item, M); } g_string_free (to_resolve, TRUE); @@ -1566,7 +1568,7 @@ surbl_dns_ip_callback (struct rdns_reply *reply, gpointer arg) } - rspamd_symcache_item_async_dec_check (param->task, param->item); + rspamd_symcache_item_async_dec_check (param->task, param->item, M); } static void @@ -1575,7 +1577,7 @@ free_redirector_session (void *ud) struct redirector_param *param = (struct redirector_param *)ud; if (param->item) { - rspamd_symcache_item_async_dec_check (param->task, param->item); + rspamd_symcache_item_async_dec_check (param->task, param->item, M); } rspamd_http_connection_unref (param->conn); @@ -1712,11 +1714,11 @@ register_redirector_call (struct rspamd_url *url, struct rspamd_task *task, rspamd_session_add_event (task->s, free_redirector_session, param, - g_quark_from_static_string ("surbl")); + M); param->item = rspamd_symbols_cache_get_cur_item (task); if (param->item) { - rspamd_symcache_item_async_inc (param->task, param->item); + rspamd_symcache_item_async_inc (param->task, param->item, M); } rspamd_http_connection_write_message (param->conn, msg, NULL, @@ -1919,7 +1921,7 @@ surbl_test_url (struct rspamd_task *task, param->tree); g_hash_table_foreach (task->urls, surbl_tree_url_callback, param); - rspamd_symcache_item_async_inc (task, item); + rspamd_symcache_item_async_inc (task, item, M); /* We also need to check and process img URLs */ if (suffix->options & SURBL_OPTION_CHECKIMAGES) { @@ -1966,7 +1968,7 @@ surbl_test_url (struct rspamd_task *task, } } - rspamd_symcache_item_async_dec_check (task, item); + rspamd_symcache_item_async_dec_check (task, item, M); } static void @@ -1987,7 +1989,7 @@ surbl_test_redirector (struct rspamd_task *task, return; } - rspamd_symcache_item_async_inc (task, item); + rspamd_symcache_item_async_inc (task, item, M); param = rspamd_mempool_alloc0 (task->task_pool, sizeof (*param)); param->task = task; @@ -1995,7 +1997,7 @@ surbl_test_redirector (struct rspamd_task *task, param->redirector_requests = 0; param->ctx = surbl_module_ctx; param->item = item; - rspamd_symcache_item_async_inc (task, item); + rspamd_symcache_item_async_inc (task, item, M); g_hash_table_foreach (task->urls, surbl_tree_redirector_callback, param); /* We also need to check and process img URLs */ @@ -2020,7 +2022,7 @@ surbl_test_redirector (struct rspamd_task *task, } } - rspamd_symcache_item_async_dec_check (task, item); + rspamd_symcache_item_async_dec_check (task, item, M); } |