commit af97b2e: [Minor] Fix refcounts mess
Vsevolod Stakhov
vsevolod at highsecure.ru
Sat Nov 30 09:35:06 UTC 2019
Author: Vsevolod Stakhov
Date: 2019-11-30 09:29:55 +0000
URL: https://github.com/rspamd/rspamd/commit/af97b2e09bcf6ee2e7db850b66fe6a28bde9b17d (HEAD -> master)
[Minor] Fix refcounts mess
---
src/plugins/spf.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/plugins/spf.c b/src/plugins/spf.c
index 521fa3480..f24bea004 100644
--- a/src/plugins/spf.c
+++ b/src/plugins/spf.c
@@ -237,7 +237,6 @@ spf_module_config (struct rspamd_config *cfg)
{
const ucl_object_t *value;
gint res = TRUE, cb_id;
- guint cache_size;
struct spf_ctx *spf_module_ctx = spf_get_context (cfg);
if (!rspamd_config_is_module_enabled (cfg, "spf")) {
@@ -641,9 +640,14 @@ spf_symbol_callback (struct rspamd_task *task,
}
spf_cred = rspamd_spf_get_cred (task);
+ /* Refcount = 1 */
rspamd_symcache_item_async_inc (task, item, M);
if (spf_cred && spf_cred->domain) {
+ /* Refcount = 2 */
+ rspamd_symcache_item_async_inc (task, item, M);
+
+ /* spf_plugin_callback can be called immediately */
if (!rspamd_spf_resolve (task, spf_plugin_callback, item, spf_cred)) {
msg_info_task ("cannot make spf request for %s", spf_cred->domain);
rspamd_task_insert_result (task,
@@ -652,9 +656,15 @@ spf_symbol_callback (struct rspamd_task *task,
"(SPF): spf DNS fail");
}
else {
+ /* Refcount is either 2 or 1, so it'll be 3 or 2 upon increase */
rspamd_symcache_item_async_inc (task, item, M);
}
+
+ /* Refcount 3 or 2 */
+ rspamd_symcache_item_async_dec_check (task, item, M);
+ /* Refcount 2 or 1 */
}
+ /* Refcount 1 or 0 */
rspamd_symcache_item_async_dec_check (task, item, M);
}
More information about the Commits
mailing list