aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-10-26 16:06:12 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-10-26 16:06:12 +0100
commit0c20729f33f07cdcef5f7c10bde04f262c4a4574 (patch)
tree66853c7d49a7e51715ce1bc73ab12998bc28c7a9 /src
parent2ae394086bb5385ae4bc216cf694fe35692522a3 (diff)
downloadrspamd-0c20729f33f07cdcef5f7c10bde04f262c4a4574.tar.gz
rspamd-0c20729f33f07cdcef5f7c10bde04f262c4a4574.zip
[Rework] Add more traces to async events, get rid of GQuarks
Diffstat (limited to 'src')
-rw-r--r--src/libserver/dns.c8
-rw-r--r--src/libserver/events.c17
-rw-r--r--src/libserver/events.h2
-rw-r--r--src/libserver/symbols_cache.c19
-rw-r--r--src/libserver/symbols_cache.h9
-rw-r--r--src/libstat/backends/redis_backend.c15
-rw-r--r--src/libstat/learn_cache/redis_cache.c12
-rw-r--r--src/libutil/http.c2
-rw-r--r--src/lua/lua_config.c6
-rw-r--r--src/lua/lua_dns.c13
-rw-r--r--src/lua/lua_dns_resolver.c11
-rw-r--r--src/lua/lua_http.c12
-rw-r--r--src/lua/lua_redis.c16
-rw-r--r--src/lua/lua_tcp.c11
-rw-r--r--src/plugins/dkim_check.c6
-rw-r--r--src/plugins/fuzzy_check.c26
-rw-r--r--src/plugins/spf.c10
-rw-r--r--src/plugins/surbl.c28
18 files changed, 124 insertions, 99 deletions
diff --git a/src/libserver/dns.c b/src/libserver/dns.c
index 358bf7dca..966ced377 100644
--- a/src/libserver/dns.c
+++ b/src/libserver/dns.c
@@ -24,6 +24,8 @@
#include "rdns_event.h"
#include "unix-std.h"
+static const gchar *M = "rspamd dns";
+
static struct rdns_upstream_elt* rspamd_dns_select_upstream (const char *name,
size_t len, void *ups_data);
static struct rdns_upstream_elt* rspamd_dns_select_upstream_retransmit (
@@ -83,7 +85,7 @@ rspamd_dns_fin_cb (gpointer arg)
if (reqdata->item) {
rspamd_symcache_item_async_dec_check (reqdata->task,
- reqdata->item);
+ reqdata->item, M);
}
if (reqdata->pool == NULL) {
@@ -160,7 +162,7 @@ make_dns_request (struct rspamd_dns_resolver *resolver,
rspamd_session_add_event (session,
(event_finalizer_t) rspamd_dns_fin_cb,
reqdata,
- g_quark_from_static_string ("dns resolver"));
+ M);
}
}
@@ -200,7 +202,7 @@ make_dns_request_task_common (struct rspamd_task *task,
if (reqdata->item) {
/* We are inside some session */
- rspamd_symcache_item_async_inc (task, reqdata->item);
+ rspamd_symcache_item_async_inc (task, reqdata->item, M);
}
if (!forced && task->dns_requests >= task->cfg->dns_max_requests) {
diff --git a/src/libserver/events.c b/src/libserver/events.c
index db17f87d6..55e04985b 100644
--- a/src/libserver/events.c
+++ b/src/libserver/events.c
@@ -48,7 +48,7 @@ static struct rspamd_counter_data events_count;
struct rspamd_async_event {
- GQuark subsystem;
+ const gchar *subsystem;
event_finalizer_t fin;
void *user_data;
};
@@ -148,7 +148,7 @@ struct rspamd_async_event *
rspamd_session_add_event (struct rspamd_async_session *session,
event_finalizer_t fin,
gpointer user_data,
- GQuark subsystem)
+ const gchar *subsystem)
{
struct rspamd_async_event *new_event;
gint ret;
@@ -161,7 +161,7 @@ rspamd_session_add_event (struct rspamd_async_session *session,
if (!RSPAMD_SESSION_CAN_ADD_EVENT (session)) {
msg_debug_session ("skip adding event subsystem: %s: "
"session is destroying/cleaning",
- g_quark_to_string (subsystem));
+ subsystem);
return NULL;
}
@@ -176,7 +176,7 @@ rspamd_session_add_event (struct rspamd_async_session *session,
"subsystem: %s",
user_data,
kh_size (session->events),
- g_quark_to_string (subsystem));
+ subsystem);
kh_put (rspamd_events_hash, session->events, new_event, &ret);
g_assert (ret > 0);
@@ -212,8 +212,9 @@ rspamd_session_remove_event (struct rspamd_async_session *session,
msg_err_session ("cannot find event: %p(%p)", fin, ud);
kh_foreach (session->events, found_ev, t, {
msg_err_session ("existing event %s: %p(%p)",
- g_quark_to_string (found_ev->subsystem),
- found_ev->fin, found_ev->user_data);
+ found_ev->subsystem,
+ found_ev->fin,
+ found_ev->user_data);
});
(void)t;
@@ -226,7 +227,7 @@ rspamd_session_remove_event (struct rspamd_async_session *session,
"subsystem: %s",
ud,
kh_size (session->events),
- g_quark_to_string (found_ev->subsystem));
+ found_ev->subsystem);
kh_del (rspamd_events_hash, session->events, k);
/* Remove event */
@@ -271,7 +272,7 @@ rspamd_session_cleanup (struct rspamd_async_session *session)
/* Call event's finalizer */
msg_debug_session ("removed event on destroy: %p, subsystem: %s",
ev->user_data,
- g_quark_to_string (ev->subsystem));
+ ev->subsystem);
if (ev->fin != NULL) {
ev->fin (ev->user_data);
diff --git a/src/libserver/events.h b/src/libserver/events.h
index 85d4e48e2..1cb5dfa11 100644
--- a/src/libserver/events.h
+++ b/src/libserver/events.h
@@ -49,7 +49,7 @@ struct rspamd_async_event *
rspamd_session_add_event (struct rspamd_async_session *session,
event_finalizer_t fin,
gpointer user_data,
- GQuark subsystem);
+ const gchar *subsystem);
/**
* Remove normal event
diff --git a/src/libserver/symbols_cache.c b/src/libserver/symbols_cache.c
index bf882c4dd..e754e2d10 100644
--- a/src/libserver/symbols_cache.c
+++ b/src/libserver/symbols_cache.c
@@ -2677,19 +2677,21 @@ rspamd_symbols_cache_finalize_item (struct rspamd_task *task,
guint
rspamd_symcache_item_async_inc (struct rspamd_task *task,
- struct rspamd_symcache_item *item)
+ struct rspamd_symcache_item *item,
+ const gchar *subsystem)
{
- msg_debug_cache_task ("increase async events counter for %s(%d) = %d + 1",
- item->symbol, item->id, item->async_events);
+ msg_debug_cache_task ("increase async events counter for %s(%d) = %d + 1; subsystem %s",
+ item->symbol, item->id, item->async_events, subsystem);
return ++item->async_events;
}
guint
rspamd_symcache_item_async_dec (struct rspamd_task *task,
- struct rspamd_symcache_item *item)
+ struct rspamd_symcache_item *item,
+ const gchar *subsystem)
{
- msg_debug_cache_task ("decrease async events counter for %s(%d) = %d - 1",
- item->symbol, item->id, item->async_events);
+ msg_debug_cache_task ("decrease async events counter for %s(%d) = %d - 1; subsystem %s",
+ item->symbol, item->id, item->async_events, subsystem);
g_assert (item->async_events > 0);
return --item->async_events;
@@ -2697,9 +2699,10 @@ rspamd_symcache_item_async_dec (struct rspamd_task *task,
gboolean
rspamd_symcache_item_async_dec_check (struct rspamd_task *task,
- struct rspamd_symcache_item *item)
+ struct rspamd_symcache_item *item,
+ const gchar *subsystem)
{
- if (rspamd_symcache_item_async_dec (task, item) == 0) {
+ if (rspamd_symcache_item_async_dec (task, item, subsystem) == 0) {
rspamd_symbols_cache_finalize_item (task, item);
return TRUE;
diff --git a/src/libserver/symbols_cache.h b/src/libserver/symbols_cache.h
index 4dce60b46..73a46c270 100644
--- a/src/libserver/symbols_cache.h
+++ b/src/libserver/symbols_cache.h
@@ -316,12 +316,14 @@ void rspamd_symbols_cache_finalize_item (struct rspamd_task *task,
* Increase number of async events pending for an item
*/
guint rspamd_symcache_item_async_inc (struct rspamd_task *task,
- struct rspamd_symcache_item *item);
+ struct rspamd_symcache_item *item,
+ const gchar *subsystem);
/*
* Decrease number of async events pending for an item, asserts if no events pending
*/
guint rspamd_symcache_item_async_dec (struct rspamd_task *task,
- struct rspamd_symcache_item *item);
+ struct rspamd_symcache_item *item,
+ const gchar *subsystem);
/**
* Decrease number of async events pending for an item, asserts if no events pending
@@ -331,5 +333,6 @@ guint rspamd_symcache_item_async_dec (struct rspamd_task *task,
* @return
*/
gboolean rspamd_symcache_item_async_dec_check (struct rspamd_task *task,
- struct rspamd_symcache_item *item);
+ struct rspamd_symcache_item *item,
+ const gchar *subsystem);
#endif
diff --git a/src/libstat/backends/redis_backend.c b/src/libstat/backends/redis_backend.c
index 113e93df9..ea032a229 100644
--- a/src/libstat/backends/redis_backend.c
+++ b/src/libstat/backends/redis_backend.c
@@ -105,13 +105,14 @@ struct rspamd_redis_stat_cbdata {
#define GET_TASK_ELT(task, elt) (task == NULL ? NULL : (task)->elt)
+static const gchar *M = "redis statistics";
+
static GQuark
rspamd_redis_stat_quark (void)
{
- return g_quark_from_static_string ("redis-statistics");
+ return g_quark_from_static_string (M);
}
-
/*
* Non-static for lua unit testing
*/
@@ -1198,7 +1199,7 @@ rspamd_redis_processed (redisAsyncContext *c, gpointer r, gpointer priv)
if (rt->has_event) {
if (rt->item) {
- rspamd_symcache_item_async_dec_check (task, rt->item);
+ rspamd_symcache_item_async_dec_check (task, rt->item, M);
}
rspamd_session_remove_event (task->s, rspamd_redis_fin, rt);
@@ -1234,7 +1235,7 @@ rspamd_redis_learned (redisAsyncContext *c, gpointer r, gpointer priv)
if (rt->has_event) {
if (rt->item) {
- rspamd_symcache_item_async_dec_check (task, rt->item);
+ rspamd_symcache_item_async_dec_check (task, rt->item, M);
}
rspamd_session_remove_event (task->s, rspamd_redis_fin_learn, rt);
@@ -1603,8 +1604,7 @@ rspamd_redis_process_tokens (struct rspamd_task *task,
if (redisAsyncCommand (rt->redis, rspamd_redis_connected, rt, "HGET %s %s",
rt->redis_object_expanded, learned_key) == REDIS_OK) {
- rspamd_session_add_event (task->s,
- rspamd_redis_fin, rt, rspamd_redis_stat_quark ());
+ rspamd_session_add_event (task->s, rspamd_redis_fin, rt, M);
rt->item = rspamd_symbols_cache_get_cur_item (task);
rt->has_event = TRUE;
@@ -1809,8 +1809,7 @@ rspamd_redis_learn_tokens (struct rspamd_task *task, GPtrArray *tokens,
"RSIG");
}
- rspamd_session_add_event (task->s,
- rspamd_redis_fin_learn, rt, rspamd_redis_stat_quark ());
+ rspamd_session_add_event (task->s, rspamd_redis_fin_learn, rt, M);
rt->item = rspamd_symbols_cache_get_cur_item (task);
rt->has_event = TRUE;
diff --git a/src/libstat/learn_cache/redis_cache.c b/src/libstat/learn_cache/redis_cache.c
index 789991186..2fbf8bc4e 100644
--- a/src/libstat/learn_cache/redis_cache.c
+++ b/src/libstat/learn_cache/redis_cache.c
@@ -28,6 +28,8 @@
#define REDIS_DEFAULT_PORT 6379
#define DEFAULT_REDIS_KEY "learned_ids"
+static const gchar *M = "redis learn cache";
+
struct rspamd_redis_cache_ctx {
struct rspamd_statfile_config *stcf;
struct upstream_list *read_servers;
@@ -51,7 +53,7 @@ struct rspamd_redis_cache_runtime {
static GQuark
rspamd_stat_cache_redis_quark (void)
{
- return g_quark_from_static_string ("redis-statistics");
+ return g_quark_from_static_string (M);
}
static void
@@ -153,7 +155,7 @@ rspamd_stat_cache_redis_get (redisAsyncContext *c, gpointer r, gpointer priv)
if (rt->has_event) {
if (rt->item) {
- rspamd_symcache_item_async_dec_check (task, rt->item);
+ rspamd_symcache_item_async_dec_check (task, rt->item, M);
}
rspamd_session_remove_event (task->s, rspamd_redis_cache_fin, rt);
}
@@ -178,7 +180,7 @@ rspamd_stat_cache_redis_set (redisAsyncContext *c, gpointer r, gpointer priv)
if (rt->has_event) {
if (rt->item) {
- rspamd_symcache_item_async_dec_check (task, rt->item);
+ rspamd_symcache_item_async_dec_check (task, rt->item, M);
}
rspamd_session_remove_event (task->s, rspamd_redis_cache_fin, rt);
}
@@ -463,7 +465,7 @@ rspamd_stat_cache_redis_check (struct rspamd_task *task,
rspamd_session_add_event (task->s,
rspamd_redis_cache_fin,
rt,
- rspamd_stat_cache_redis_quark ());
+ M);
rt->item = rspamd_symbols_cache_get_cur_item (task);
event_add (&rt->timeout_event, &tv);
rt->has_event = TRUE;
@@ -497,7 +499,7 @@ rspamd_stat_cache_redis_learn (struct rspamd_task *task,
"HSET %s %s %d",
rt->ctx->redis_object, h, flag) == REDIS_OK) {
rspamd_session_add_event (task->s,
- rspamd_redis_cache_fin, rt, rspamd_stat_cache_redis_quark ());
+ rspamd_redis_cache_fin, rt, M);
rt->item = rspamd_symbols_cache_get_cur_item (task);
event_add (&rt->timeout_event, &tv);
rt->has_event = TRUE;
diff --git a/src/libutil/http.c b/src/libutil/http.c
index 3936ac34c..7fe64d828 100644
--- a/src/libutil/http.c
+++ b/src/libutil/http.c
@@ -2186,7 +2186,7 @@ rspamd_http_connection_write_message_common (struct rspamd_http_connection *conn
}
else {
/* Invalid body for spamc method */
- g_assert (0);
+ g_abort ();
}
}
diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c
index 69f50acff..bfe82f7ea 100644
--- a/src/lua/lua_config.c
+++ b/src/lua/lua_config.c
@@ -1107,7 +1107,7 @@ lua_metric_symbol_callback (struct rspamd_task *task,
struct rspamd_task **ptask;
struct thread_entry *thread_entry;
- rspamd_symcache_item_async_inc (task, item);
+ rspamd_symcache_item_async_inc (task, item, "lua symbol");
thread_entry = lua_thread_pool_get_for_task (task);
g_assert(thread_entry->cd == NULL);
@@ -1143,7 +1143,7 @@ lua_metric_symbol_callback_error (struct thread_entry *thread_entry,
struct rspamd_task *task = thread_entry->task;
msg_err_task ("call to (%s) failed (%d): %s", cd->symbol, ret, msg);
- rspamd_symcache_item_async_dec_check (task, cd->item);
+ rspamd_symcache_item_async_dec_check (task, cd->item, "lua symbol");
}
static void
@@ -1224,7 +1224,7 @@ lua_metric_symbol_callback_return (struct thread_entry *thread_entry, int ret)
g_assert (lua_gettop (L) == cd->stack_level); /* we properly cleaned up the stack */
cd->stack_level = 0;
- rspamd_symcache_item_async_dec_check (task, cd->item);
+ rspamd_symcache_item_async_dec_check (task, cd->item, "lua symbol");
}
static gint
diff --git a/src/lua/lua_dns.c b/src/lua/lua_dns.c
index da026a8a3..632ff6f1b 100644
--- a/src/lua/lua_dns.c
+++ b/src/lua/lua_dns.c
@@ -23,8 +23,9 @@ static const struct luaL_reg dns_f[] = {
{NULL, NULL}
};
-void
-lua_dns_callback (struct rdns_reply *reply, void *arg);
+static const gchar *M = "rspamd lua dns";
+
+void lua_dns_callback (struct rdns_reply *reply, void *arg);
struct lua_rspamd_dns_cbdata {
struct thread_entry *thread;
@@ -109,13 +110,13 @@ lua_dns_request (lua_State *L)
if (task == NULL) {
- ret = make_dns_request (cfg->dns_resolver,
+ ret = (make_dns_request (cfg->dns_resolver,
session,
pool,
lua_dns_callback,
cbdata,
type,
- to_resolve);
+ to_resolve) != NULL);
}
else {
if (forced) {
@@ -140,7 +141,7 @@ lua_dns_request (lua_State *L)
if (task) {
cbdata->item = rspamd_symbols_cache_get_cur_item (task);
- rspamd_symcache_item_async_inc (task, cbdata->item);
+ rspamd_symcache_item_async_inc (task, cbdata->item, M);
}
return lua_thread_yield (cbdata->thread, 0);
@@ -176,7 +177,7 @@ lua_dns_callback (struct rdns_reply *reply, void *arg)
lua_thread_resume (cbdata->thread, 2);
if (cbdata->item) {
- rspamd_symcache_item_async_dec_check (cbdata->task, cbdata->item);
+ rspamd_symcache_item_async_dec_check (cbdata->task, cbdata->item, M);
}
}
diff --git a/src/lua/lua_dns_resolver.c b/src/lua/lua_dns_resolver.c
index c95d7bbba..6c46c12cf 100644
--- a/src/lua/lua_dns_resolver.c
+++ b/src/lua/lua_dns_resolver.c
@@ -40,6 +40,9 @@ local function symbol_callback(task)
task:get_resolver():resolve_a({task = task, name = host, callback = dns_cb})
end
*/
+
+static const gchar *M = "rspamd lua dns resolver";
+
struct rspamd_dns_resolver * lua_check_dns_resolver (lua_State * L);
void luaopen_dns_resolver (lua_State * L);
@@ -204,7 +207,7 @@ lua_dns_resolver_callback (struct rdns_reply *reply, gpointer arg)
lua_thread_pool_restore_callback (&cbs);
if (cd->item) {
- rspamd_symcache_item_async_dec_check (cd->task, cd->item);
+ rspamd_symcache_item_async_dec_check (cd->task, cd->item, M);
}
if (!cd->pool) {
@@ -447,7 +450,7 @@ lua_dns_resolver_resolve_common (lua_State *L,
* lua_dns_resolver_callback without switching to the event loop
*/
if (cbdata->item) {
- rspamd_symcache_item_async_inc (task, cbdata->item);
+ rspamd_symcache_item_async_inc (task, cbdata->item, M);
}
if (forced) {
@@ -469,7 +472,7 @@ lua_dns_resolver_resolve_common (lua_State *L,
cbdata->item = rspamd_symbols_cache_get_cur_item (task);
if (cbdata->item) {
- rspamd_symcache_item_async_inc (task, cbdata->item);
+ rspamd_symcache_item_async_inc (task, cbdata->item, M);
}
/* callback was set up */
lua_pushboolean (L, TRUE);
@@ -479,7 +482,7 @@ lua_dns_resolver_resolve_common (lua_State *L,
}
if (cbdata->item) {
- rspamd_symcache_item_async_dec_check (task, cbdata->item);
+ rspamd_symcache_item_async_dec_check (task, cbdata->item, M);
}
}
}
diff --git a/src/lua/lua_http.c b/src/lua/lua_http.c
index bd7cd97b7..e8276e485 100644
--- a/src/lua/lua_http.c
+++ b/src/lua/lua_http.c
@@ -45,6 +45,8 @@ local function symbol_callback(task)
#define MAX_HEADERS_SIZE 8192
+static const gchar *M = "rspamd lua http";
+
LUA_FUNCTION_DEF (http, request);
static const struct luaL_reg httplib_m[] = {
@@ -151,7 +153,7 @@ lua_http_maybe_free (struct lua_http_cbdata *cbd)
if (cbd->flags & RSPAMD_LUA_HTTP_FLAG_RESOLVED) {
/* Event is added merely for resolved events */
if (cbd->item) {
- rspamd_symcache_item_async_dec_check (cbd->task, cbd->item);
+ rspamd_symcache_item_async_dec_check (cbd->task, cbd->item, M);
}
rspamd_session_remove_event (cbd->session, lua_http_fin, cbd);
@@ -422,12 +424,12 @@ lua_http_make_connection (struct lua_http_cbdata *cbd)
if (cbd->session) {
rspamd_session_add_event (cbd->session,
(event_finalizer_t) lua_http_fin, cbd,
- g_quark_from_static_string ("lua http"));
+ M);
cbd->flags |= RSPAMD_LUA_HTTP_FLAG_RESOLVED;
}
if (cbd->item) {
- rspamd_symcache_item_async_inc (cbd->task, cbd->item);
+ rspamd_symcache_item_async_inc (cbd->task, cbd->item, M);
}
return TRUE;
@@ -464,7 +466,7 @@ lua_http_dns_handler (struct rdns_reply *reply, gpointer ud)
}
if (cbd->item) {
- rspamd_symcache_item_async_dec_check (cbd->task, cbd->item);
+ rspamd_symcache_item_async_dec_check (cbd->task, cbd->item, M);
}
}
@@ -947,7 +949,7 @@ lua_http_request (lua_State *L)
return 1;
}
else if (cbd->item) {
- rspamd_symcache_item_async_inc (cbd->task, cbd->item);
+ rspamd_symcache_item_async_inc (cbd->task, cbd->item, M);
}
}
}
diff --git a/src/lua/lua_redis.c b/src/lua/lua_redis.c
index a1f62b72d..be694a0e6 100644
--- a/src/lua/lua_redis.c
+++ b/src/lua/lua_redis.c
@@ -22,6 +22,8 @@
#define REDIS_DEFAULT_TIMEOUT 1.0
+static const gchar *M = "rspamd lua redis";
+
/***
* @module rspamd_redis
* This module implements redis asynchronous client for rspamd LUA API.
@@ -292,7 +294,7 @@ lua_redis_push_error (const gchar *err,
if (connected && ud->s) {
if (ud->item) {
- rspamd_symcache_item_async_dec_check (ud->task, ud->item);
+ rspamd_symcache_item_async_dec_check (ud->task, ud->item, M);
}
rspamd_session_remove_event (ud->s, lua_redis_fin, sp_ud);
@@ -382,7 +384,7 @@ lua_redis_push_data (const redisReply *r, struct lua_redis_ctx *ctx,
if (ud->s) {
if (ud->item) {
- rspamd_symcache_item_async_dec_check (ud->task, ud->item);
+ rspamd_symcache_item_async_dec_check (ud->task, ud->item, M);
}
rspamd_session_remove_event (ud->s, lua_redis_fin, sp_ud);
@@ -502,7 +504,7 @@ lua_redis_cleanup_events (struct lua_redis_ctx *ctx)
struct lua_redis_result *result = g_queue_pop_head (ctx->events_cleanup);
if (result->item) {
- rspamd_symcache_item_async_dec_check (result->task, result->item);
+ rspamd_symcache_item_async_dec_check (result->task, result->item, M);
}
rspamd_session_remove_event (result->s, lua_redis_fin, result->sp_ud);
@@ -1051,10 +1053,10 @@ lua_redis_make_request (lua_State *L)
if (ud->s) {
rspamd_session_add_event (ud->s,
lua_redis_fin, sp_ud,
- g_quark_from_static_string ("lua redis"));
+ M);
if (ud->item) {
- rspamd_symcache_item_async_inc (ud->task, ud->item);
+ rspamd_symcache_item_async_inc (ud->task, ud->item, M);
}
}
@@ -1420,10 +1422,10 @@ lua_redis_add_cmd (lua_State *L)
rspamd_session_add_event (ud->s,
lua_redis_fin,
sp_ud,
- g_quark_from_static_string ("lua redis"));
+ M);
if (ud->item) {
- rspamd_symcache_item_async_inc (ud->task, ud->item);
+ rspamd_symcache_item_async_inc (ud->task, ud->item, M);
}
}
diff --git a/src/lua/lua_tcp.c b/src/lua/lua_tcp.c
index c6e96825b..375867df6 100644
--- a/src/lua/lua_tcp.c
+++ b/src/lua/lua_tcp.c
@@ -19,6 +19,8 @@
#include "unix-std.h"
#include <math.h>
+static const gchar *M = "rspamd lua tcp";
+
/***
* @module rspamd_tcp
* Rspamd TCP module represents generic TCP asynchronous client available from LUA code.
@@ -483,7 +485,7 @@ lua_tcp_maybe_free (struct lua_tcp_cbdata *cbd)
*/
if (cbd->item) {
- rspamd_symcache_item_async_dec_check (cbd->task, cbd->item);
+ rspamd_symcache_item_async_dec_check (cbd->task, cbd->item, M);
cbd->item = NULL;
}
@@ -495,7 +497,7 @@ lua_tcp_maybe_free (struct lua_tcp_cbdata *cbd)
}
else {
if (cbd->item) {
- rspamd_symcache_item_async_dec_check (cbd->task, cbd->item);
+ rspamd_symcache_item_async_dec_check (cbd->task, cbd->item, M);
cbd->item = NULL;
}
@@ -1161,8 +1163,7 @@ lua_tcp_register_event (struct lua_tcp_cbdata *cbd)
if (cbd->session) {
event_finalizer_t fin = IS_SYNC (cbd) ? lua_tcp_void_finalyser : lua_tcp_fin;
- cbd->async_ev = rspamd_session_add_event (cbd->session, fin, cbd,
- g_quark_from_static_string ("lua tcp"));
+ cbd->async_ev = rspamd_session_add_event (cbd->session, fin, cbd, M);
if (!cbd->async_ev) {
return FALSE;
@@ -1176,7 +1177,7 @@ static void
lua_tcp_register_watcher (struct lua_tcp_cbdata *cbd)
{
if (cbd->item) {
- rspamd_symcache_item_async_inc (cbd->task, cbd->item);
+ rspamd_symcache_item_async_inc (cbd->task, cbd->item, M);
}
}
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);
}