]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Rework] Add more traces to async events, get rid of GQuarks
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 26 Oct 2018 15:06:12 +0000 (16:06 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 26 Oct 2018 15:06:12 +0000 (16:06 +0100)
18 files changed:
src/libserver/dns.c
src/libserver/events.c
src/libserver/events.h
src/libserver/symbols_cache.c
src/libserver/symbols_cache.h
src/libstat/backends/redis_backend.c
src/libstat/learn_cache/redis_cache.c
src/libutil/http.c
src/lua/lua_config.c
src/lua/lua_dns.c
src/lua/lua_dns_resolver.c
src/lua/lua_http.c
src/lua/lua_redis.c
src/lua/lua_tcp.c
src/plugins/dkim_check.c
src/plugins/fuzzy_check.c
src/plugins/spf.c
src/plugins/surbl.c

index 358bf7dca6a06169f1e7afc731bbb9a579175b46..966ced377e67331c6381de276abc9464c131e30a 100644 (file)
@@ -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) {
index db17f87d66e160c0e5c0c00e367ba101a67de0b7..55e04985b8952c6dc20d75e3ef2a4ee2a9ce6cd0 100644 (file)
@@ -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);
index 85d4e48e2235acab54c049e94a8494a1eacbdec0..1cb5dfa11315ca8988f3a7ac8cd9aa939104371e 100644 (file)
@@ -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
index bf882c4dd9dbb1e11918a927321ec8b494ede823..e754e2d10e96b24e9f4fb8b3a1072468f71c680a 100644 (file)
@@ -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;
index 4dce60b4642586238604ddf316245da988b82587..73a46c27091feae6eb4e02647c3c99a5d80ddcff 100644 (file)
@@ -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
index 113e93df9cac31333c791162809c2c9d4ed5ce51..ea032a2296ab33c393a2b6df4e50f07c537344ee 100644 (file)
@@ -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;
 
index 789991186e5711f53051fbb48d015843c775de60..2fbf8bc4e03ea656fde76d1fbbbbda05280eed77 100644 (file)
@@ -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;
index 3936ac34cfbc506a67ccb3cf4282d3269b5ed70d..7fe64d82895d0116624cdd39d5b4a4d48fe80ee1 100644 (file)
@@ -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 ();
                }
        }
 
index 69f50acff5f474f82ee64f4b2cddac896eda6541..bfe82f7ea0a7feb0b5cab0d7628b691c7a07a6bc 100644 (file)
@@ -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
index da026a8a322aa765d3562d014fc769923bf207b6..632ff6f1bd4825dcd559ec9b89744cdfff483010 100644 (file)
@@ -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);
        }
 }
 
index c95d7bbbac4b6cc53d9817d12d350063131013e8..6c46c12cf0b68aae71a884f4de5662068599f876 100644 (file)
@@ -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);
                        }
                }
        }
index bd7cd97b777595c6faa16ab4a1889f5d8ea62d5d..e8276e485cf16e765e81e57d4799b063443b0f65 100644 (file)
@@ -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);
                        }
                }
        }
index a1f62b72db9fc8329e560a9eb1aea433f5c2efef..be694a0e651fc291f48aa9c4bf7127cccdda9c86 100644 (file)
@@ -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);
                                }
                        }
 
index c6e96825b61723c00f190fbd8ec199086de4845b..375867df625e75065ab1d5b40e445a0583f902a1 100644 (file)
@@ -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);
        }
 }
 
index f1a67085ea36caf59d7cd45b4ae60c8f394afd3e..ae4b0f04d59ac64eafea929aeda8a77af28f8dff 100644 (file)
@@ -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
index 3da793adc028f57b019035905502838c95dbcdb2..e61fa7ce3b19b11b1b9f005fb651e95ebe2d633c 100644 (file)
@@ -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;
index c3337a4ebc7aaf19a21069d050456c3b9905ff93..271fd18920b5a329fb490c43d9f59fa98cb66ca1 100644 (file)
@@ -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);
 }
index 8070bfb239bbb8427cf62edfdb0974fe433ed9ae..4c3fbefa1ffaaea4dea33afe3d132a8c1a8b0bed 100644 (file)
@@ -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);
 }