gchar *local_part;
struct rspamd_task *task;
spf_cb_t callback;
+ gpointer cbdata;
gboolean done;
};
if (rec->requests_inflight == 0 && !rec->done) {
flat = rspamd_spf_record_flatten (rec);
- rec->callback (flat, rec->task);
+ rec->callback (flat, rec->task, rec->cbdata);
REF_RELEASE (flat);
rec->done = TRUE;
}
}
gboolean
-resolve_spf (struct rspamd_task *task, spf_cb_t callback)
+rspamd_spf_resolve (struct rspamd_task *task, spf_cb_t callback,
+ gpointer cbdata)
{
struct spf_record *rec;
struct rspamd_spf_cred *cred;
rec = rspamd_mempool_alloc0 (task->task_pool, sizeof (struct spf_record));
rec->task = task;
rec->callback = callback;
+ rec->cbdata = cbdata;
rec->resolved = g_ptr_array_sized_new (8);
struct rspamd_task;
struct spf_resolved;
-typedef void (*spf_cb_t)(struct spf_resolved *record, struct rspamd_task *task);
+typedef void (*spf_cb_t)(struct spf_resolved *record,
+ struct rspamd_task *task, gpointer cbdata);
typedef enum spf_mech_e {
SPF_FAIL,
/*
* Resolve spf record for specified task and call a callback after resolution fails/succeed
*/
-gboolean resolve_spf (struct rspamd_task *task, spf_cb_t callback);
+gboolean rspamd_spf_resolve (struct rspamd_task *task, spf_cb_t callback,
+ gpointer cbdata);
/*
* Get a domain for spf for specified task
RSPAMD_MODULE_VER
};
-static GQuark
-spf_plugin_quark (void)
-{
- return g_quark_from_static_string ("spf-plugin");
-}
-
-static void
-spf_plugin_fin (gpointer ud)
-{
-
-}
-
gint
spf_module_init (struct rspamd_config *cfg, struct module_ctx **ctx)
{
}
static void
-spf_plugin_callback (struct spf_resolved *record, struct rspamd_task *task)
+spf_plugin_callback (struct spf_resolved *record, struct rspamd_task *task,
+ gpointer ud)
{
struct spf_resolved *l;
+ struct rspamd_async_watcher *w = ud;
if (record && record->elts->len > 0 && record->domain) {
spf_record_unref (l);
}
- rspamd_session_remove_event (task->s, spf_plugin_fin, NULL);
+ rspamd_session_watcher_pop (task->s, w);
}
{
const gchar *domain;
struct spf_resolved *l;
+ struct rspamd_async_watcher *w;
if (radix_find_compressed_addr (spf_module_ctx->whitelist_ip,
task->from_addr) != RADIX_NO_VALUE) {
spf_record_unref (l);
}
else {
- if (!resolve_spf (task, spf_plugin_callback)) {
+ w = rspamd_session_get_watcher (task->s);
+ if (!rspamd_spf_resolve (task, spf_plugin_callback, w)) {
msg_info_task ("cannot make spf request for [%s]",
task->message_id);
}
else {
- rspamd_session_add_event (task->s, spf_plugin_fin, NULL,
- spf_plugin_quark ());
+ rspamd_session_watcher_push (task->s);
}
}
}