aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/libserver/spf.c30
-rw-r--r--src/libserver/spf.h9
2 files changed, 28 insertions, 11 deletions
diff --git a/src/libserver/spf.c b/src/libserver/spf.c
index ec8decb50..d21789c01 100644
--- a/src/libserver/spf.c
+++ b/src/libserver/spf.c
@@ -111,6 +111,10 @@ struct rspamd_spf_library_ctx *spf_lib_ctx = NULL;
rspamd_spf_log_id, "spf", rec->task->task_pool->tag.uid, \
G_STRFUNC, \
__VA_ARGS__)
+#define msg_debug_spf_flatten(...) rspamd_conditional_debug_fast_num_id (NULL, NULL, \
+ rspamd_spf_log_id, "spf", (flat)->digest, \
+ G_STRFUNC, \
+ __VA_ARGS__)
INIT_LOG_MODULE(spf)
@@ -157,6 +161,14 @@ RSPAMD_DESTRUCTOR(rspamd_spf_lib_ctx_dtor) {
spf_lib_ctx = NULL;
}
+static void
+spf_record_cached_unref_dtor (gpointer p)
+{
+ struct spf_resolved *flat = (struct spf_resolved *)p;
+
+ _spf_record_unref (flat, "LRU cache");
+}
+
void
spf_library_config (const ucl_object_t *obj)
{
@@ -208,7 +220,7 @@ spf_library_config (const ucl_object_t *obj)
spf_lib_ctx->spf_hash = rspamd_lru_hash_new (
ival,
NULL,
- (GDestroyNotify) spf_record_unref);
+ spf_record_cached_unref_dtor);
}
}
else {
@@ -216,7 +228,7 @@ spf_library_config (const ucl_object_t *obj)
spf_lib_ctx->spf_hash = rspamd_lru_hash_new (
2048,
NULL,
- (GDestroyNotify) spf_record_unref);
+ spf_record_cached_unref_dtor);
}
}
@@ -608,7 +620,7 @@ rspamd_spf_maybe_return (struct spf_record *rec)
}
rec->callback (flat, rec->task, rec->cbdata);
- REF_RELEASE (flat);
+ spf_record_unref (flat);
rec->done = TRUE;
}
}
@@ -2471,16 +2483,18 @@ rspamd_spf_resolve (struct rspamd_task *task, spf_cb_t callback,
}
struct spf_resolved *
-spf_record_ref (struct spf_resolved *rec)
+_spf_record_ref (struct spf_resolved *flat, const gchar *loc)
{
- REF_RETAIN (rec);
- return rec;
+ msg_debug_spf_flatten ("record ref %s; refcount=%d++", loc, flat->ref.refcount);
+ REF_RETAIN (flat);
+ return flat;
}
void
-spf_record_unref (struct spf_resolved *rec)
+_spf_record_unref (struct spf_resolved *flat, const gchar *loc)
{
- REF_RELEASE (rec);
+ msg_debug_spf_flatten ("record unref %s; refcount=%d--", loc, flat->ref.refcount);
+ REF_RELEASE (flat);
}
gchar *
diff --git a/src/libserver/spf.h b/src/libserver/spf.h
index 1a0d8bfcf..6fd3e1583 100644
--- a/src/libserver/spf.h
+++ b/src/libserver/spf.h
@@ -108,12 +108,15 @@ struct rspamd_spf_cred *rspamd_spf_get_cred (struct rspamd_task *task);
/*
* Increase refcount
*/
-struct spf_resolved *spf_record_ref (struct spf_resolved *rec);
-
+struct spf_resolved *_spf_record_ref (struct spf_resolved *rec, const gchar *loc);
+#define spf_record_ref(rec) \
+ _spf_record_ref ((rec), G_STRLOC)
/*
* Decrease refcount
*/
-void spf_record_unref (struct spf_resolved *rec);
+void _spf_record_unref (struct spf_resolved *rec, const gchar *loc);
+#define spf_record_unref(rec) \
+ _spf_record_unref((rec), G_STRLOC)
/**
* Prints address + mask in a freshly allocated string (must be freed)