aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-10-20 18:32:25 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-10-20 19:43:32 +0100
commitf76b1582238a3ee7f45308f1df4f840c21b946a8 (patch)
treeade86728e44d37eadd73ac588936b88eda6f69a2 /src/plugins
parent251a7c9d11a676a58f22edb8afd09f20c69bd61f (diff)
downloadrspamd-f76b1582238a3ee7f45308f1df4f840c21b946a8.tar.gz
rspamd-f76b1582238a3ee7f45308f1df4f840c21b946a8.zip
[Project] Adopt C modules and stuff
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/dkim_check.c10
-rw-r--r--src/plugins/fuzzy_check.c13
-rw-r--r--src/plugins/spf.c10
-rw-r--r--src/plugins/surbl.c5
4 files changed, 24 insertions, 14 deletions
diff --git a/src/plugins/dkim_check.c b/src/plugins/dkim_check.c
index 945b92e04..da42fe14f 100644
--- a/src/plugins/dkim_check.c
+++ b/src/plugins/dkim_check.c
@@ -86,7 +86,7 @@ struct dkim_check_result {
gint res;
gdouble mult_allow;
gdouble mult_deny;
- struct rspamd_async_watcher *w;
+ struct rspamd_symcache_item *item;
struct dkim_check_result *next, *prev, *first;
};
@@ -1029,7 +1029,8 @@ dkim_module_check (struct dkim_check_result *res)
tracebuf);
}
}
- rspamd_session_watcher_pop (res->task->s, res->w);
+
+ rspamd_symcache_item_async_dec_check (res->task, res->item);
}
}
@@ -1147,6 +1148,7 @@ dkim_symbol_callback (struct rspamd_task *task,
cur->task = task;
cur->mult_allow = 1.0;
cur->mult_deny = 1.0;
+ cur->item = item;
ctx = rspamd_create_dkim_context (rh->decoded,
task->task_pool,
@@ -1207,10 +1209,8 @@ dkim_symbol_callback (struct rspamd_task *task,
res = cur;
res->first = res;
res->prev = res;
- res->w = rspamd_session_get_watcher (task->s);
}
else {
- cur->w = res->w;
DL_APPEND (res, cur);
}
@@ -1232,7 +1232,7 @@ dkim_symbol_callback (struct rspamd_task *task,
}
if (res != NULL) {
- rspamd_session_watcher_push (task->s);
+ rspamd_symcache_item_async_inc (task, item);
dkim_module_check (res);
}
}
diff --git a/src/plugins/fuzzy_check.c b/src/plugins/fuzzy_check.c
index a76f7d1e8..79ae230cf 100644
--- a/src/plugins/fuzzy_check.c
+++ b/src/plugins/fuzzy_check.c
@@ -131,6 +131,7 @@ struct fuzzy_client_session {
GPtrArray *commands;
GPtrArray *results;
struct rspamd_task *task;
+ struct rspamd_symcache_item *item;
struct upstream *server;
struct fuzzy_rule *rule;
struct event ev;
@@ -2106,6 +2107,7 @@ fuzzy_check_session_is_completed (struct fuzzy_client_session *session)
if (nreplied == session->commands->len) {
fuzzy_insert_metric_results (session->task, session->results);
+ rspamd_symcache_item_async_dec_check (session->task, session->item);
rspamd_session_remove_event (session->task->s, fuzzy_io_fin, session);
return TRUE;
@@ -2180,6 +2182,7 @@ fuzzy_check_io_callback (gint fd, short what, void *arg)
errno,
strerror (errno));
rspamd_upstream_fail (session->server, FALSE);
+ rspamd_symcache_item_async_dec_check (session->task, session->item);
rspamd_session_remove_event (session->task->s, fuzzy_io_fin, session);
}
else {
@@ -2220,6 +2223,7 @@ fuzzy_check_timer_callback (gint fd, short what, void *arg)
rspamd_upstream_addr (session->server)),
session->retransmits);
rspamd_upstream_fail (session->server, FALSE);
+ rspamd_symcache_item_async_dec_check (session->task, session->item);
rspamd_session_remove_event (session->task->s, fuzzy_io_fin, session);
}
else {
@@ -2872,8 +2876,10 @@ 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, NULL, fuzzy_io_fin, session,
+ rspamd_session_add_event (task->s, fuzzy_io_fin, session,
g_quark_from_static_string ("fuzzy check"));
+ session->item = rspamd_symbols_cache_get_cur_item (task);
+ rspamd_symcache_item_async_inc (task, session->item);
}
}
}
@@ -3346,7 +3352,10 @@ fuzzy_check_send_lua_learn (struct fuzzy_rule *rule,
event_base_set (s->task->ev_base, &s->timev);
event_add (&s->timev, &s->tv);
- rspamd_session_add_event (task->s, NULL, fuzzy_lua_fin, s, g_quark_from_static_string ("fuzzy check"));
+ rspamd_session_add_event (task->s,
+ fuzzy_lua_fin,
+ s,
+ g_quark_from_static_string ("fuzzy check"));
(*saved)++;
ret = 1;
diff --git a/src/plugins/spf.c b/src/plugins/spf.c
index cb4546f83..1ec30b4ee 100644
--- a/src/plugins/spf.c
+++ b/src/plugins/spf.c
@@ -512,7 +512,7 @@ spf_plugin_callback (struct spf_resolved *record, struct rspamd_task *task,
gpointer ud)
{
struct spf_resolved *l;
- struct rspamd_async_watcher *w = ud;
+ struct rspamd_symcache_item *item = (struct rspamd_symcache_item *)ud;
struct spf_ctx *spf_module_ctx = spf_get_context (task->cfg);
if (record && record->na) {
@@ -562,7 +562,7 @@ spf_plugin_callback (struct spf_resolved *record, struct rspamd_task *task,
spf_record_unref (l);
}
- rspamd_session_watcher_pop (task->s, w);
+ rspamd_symcache_item_async_dec_check (task, item);
}
@@ -573,7 +573,6 @@ spf_symbol_callback (struct rspamd_task *task,
{
const gchar *domain;
struct spf_resolved *l;
- struct rspamd_async_watcher *w;
gint *dmarc_checks;
struct spf_ctx *spf_module_ctx = spf_get_context (task->cfg);
@@ -616,9 +615,8 @@ spf_symbol_callback (struct rspamd_task *task,
spf_record_unref (l);
}
else {
- w = rspamd_session_get_watcher (task->s);
- if (!rspamd_spf_resolve (task, spf_plugin_callback, w)) {
+ if (!rspamd_spf_resolve (task, spf_plugin_callback, item)) {
msg_info_task ("cannot make spf request for [%s]",
task->message_id);
rspamd_task_insert_result (task,
@@ -627,7 +625,7 @@ spf_symbol_callback (struct rspamd_task *task,
"(SPF): spf DNS fail");
}
else {
- rspamd_session_watcher_push (task->s);
+ rspamd_symcache_item_async_inc (task, item);
}
}
}
diff --git a/src/plugins/surbl.c b/src/plugins/surbl.c
index 2c9acde31..0717b4679 100644
--- a/src/plugins/surbl.c
+++ b/src/plugins/surbl.c
@@ -1705,7 +1705,10 @@ register_redirector_call (struct rspamd_url *url, struct rspamd_task *task,
timeout = rspamd_mempool_alloc (task->task_pool, sizeof (struct timeval));
double_to_tv (surbl_module_ctx->read_timeout, timeout);
- rspamd_session_add_event (task->s, NULL, free_redirector_session, param, g_quark_from_static_string ("surbl"));
+ rspamd_session_add_event (task->s,
+ free_redirector_session, param,
+ g_quark_from_static_string ("surbl"));
+ param->item = rspamd_symbols_cache_get_cur_item (task);
rspamd_http_connection_write_message (param->conn, msg, NULL,
NULL, param, s, timeout, task->ev_base);