diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-02-18 14:58:06 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-02-18 14:58:06 +0000 |
commit | 6cbad30ffbc13f9ce49e8a560f5d0fb27f4557d1 (patch) | |
tree | 8172360fcb3b675965543399057e88fc486248fc /src/plugins | |
parent | 6eca77ce25118de6a6fe22a2f1c051bde8e754f5 (diff) | |
download | rspamd-6cbad30ffbc13f9ce49e8a560f5d0fb27f4557d1.tar.gz rspamd-6cbad30ffbc13f9ce49e8a560f5d0fb27f4557d1.zip |
Rework LRU hash logic.
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/dkim_check.c | 14 | ||||
-rw-r--r-- | src/plugins/spf.c | 2 |
2 files changed, 11 insertions, 5 deletions
diff --git a/src/plugins/dkim_check.c b/src/plugins/dkim_check.c index 95e07370a..b7c5515e5 100644 --- a/src/plugins/dkim_check.c +++ b/src/plugins/dkim_check.c @@ -281,14 +281,16 @@ dkim_module_key_handler (rspamd_dkim_key_t *key, gsize keylen, rspamd_dkim_conte if (key != NULL) { /* Add new key to the lru cache */ - rspamd_lru_hash_insert (dkim_module_ctx->dkim_hash, g_strdup (ctx->dns_key), key, task->tv.tv_sec); + rspamd_lru_hash_insert (dkim_module_ctx->dkim_hash, g_strdup (ctx->dns_key), + key, task->tv.tv_sec, key->ttl); dkim_module_check (task, ctx, key); } else { /* Insert tempfail symbol */ msg_info ("cannot get key for domain %s", ctx->dns_key); if (err != NULL) { - insert_result (task, dkim_module_ctx->symbol_tempfail, 1, g_list_prepend (NULL, memory_pool_strdup (task->task_pool, err->message))); + insert_result (task, dkim_module_ctx->symbol_tempfail, 1, + g_list_prepend (NULL, memory_pool_strdup (task->task_pool, err->message))); } else { @@ -322,7 +324,10 @@ dkim_symbol_callback (struct worker_task *task, void *unused) #endif /* Parse signature */ msg_debug ("create dkim signature"); - /* Check only last signature as there is no way to check embeded signatures after resend or something like this */ + /* + * Check only last signature as there is no way to check embeded signatures after + * resend or something like this + */ if (dkim_module_ctx->skip_multi) { if (hlist->next != NULL) { msg_info ("<%s> skip dkim check as it has several dkim signatures", task->message_id); @@ -337,7 +342,8 @@ dkim_symbol_callback (struct worker_task *task, void *unused) } else { /* Get key */ - if (dkim_module_ctx->trusted_only && (dkim_module_ctx->dkim_domains == NULL || g_hash_table_lookup (dkim_module_ctx->dkim_domains, ctx->domain) == NULL)) { + if (dkim_module_ctx->trusted_only && (dkim_module_ctx->dkim_domains == NULL || + g_hash_table_lookup (dkim_module_ctx->dkim_domains, ctx->domain) == NULL)) { msg_debug ("skip dkim check for %s domain", ctx->domain); return; } diff --git a/src/plugins/spf.c b/src/plugins/spf.c index 8b27174d9..99e7f664e 100644 --- a/src/plugins/spf.c +++ b/src/plugins/spf.c @@ -289,7 +289,7 @@ spf_plugin_callback (struct spf_record *record, struct worker_task *task) if ((l = rspamd_lru_hash_lookup (spf_module_ctx->spf_hash, record->sender_domain, task->tv.tv_sec)) == NULL) { l = spf_record_copy (record->addrs); rspamd_lru_hash_insert (spf_module_ctx->spf_hash, g_strdup (record->sender_domain), - l, task->tv.tv_sec); + l, task->tv.tv_sec, record->ttl); } spf_check_list (l, task); } |