static void
surbl_tree_url_callback (gpointer key, gpointer value, void *data)
{
- struct redirector_param *param = data;
+ struct redirector_param *param = data, *nparam;
struct rspamd_task *task, **ptask;
struct rspamd_url *url = value, **purl;
lua_State *L;
}
if (surbl_module_ctx->redirector_cbid != -1) {
+ nparam = rspamd_mempool_alloc (task->task_pool,
+ sizeof (*nparam));
+ /* Copy to detach from the shared param */
+ memcpy (nparam, param, sizeof (*param));
+ nparam->url = url;
L = task->cfg->lua_state;
lua_rawgeti (L, LUA_REGISTRYINDEX,
surbl_module_ctx->redirector_cbid);
purl = lua_newuserdata (L, sizeof (*purl));
*purl = url;
rspamd_lua_setclass (L, "rspamd{url}", -1);
- lua_pushlightuserdata (L, param);
+ lua_pushlightuserdata (L, nparam);
if (lua_pcall (L, 3, 0, 0) != 0) {
msg_err_task ("cannot call for redirector script: %s",
lua_pop (L, 1);
}
else {
- param->w = rspamd_session_get_watcher (task->s);
+ nparam->w = rspamd_session_get_watcher (task->s);
rspamd_session_watcher_push (task->s);
}
}
static void
surbl_test_url (struct rspamd_task *task, void *user_data)
{
- struct redirector_param param;
+ struct redirector_param *param;
struct suffix_item *suffix = user_data;
guint i, j;
struct rspamd_mime_text_part *part;
return;
}
- param.task = task;
- param.suffix = suffix;
- param.tree = g_hash_table_new (rspamd_strcase_hash, rspamd_strcase_equal);
+ param = rspamd_mempool_alloc0 (task->task_pool, sizeof (*param));
+ param->task = task;
+ param->suffix = suffix;
+ param->tree = g_hash_table_new (rspamd_strcase_hash, rspamd_strcase_equal);
rspamd_mempool_add_destructor (task->task_pool,
(rspamd_mempool_destruct_t)g_hash_table_unref,
- param.tree);
- g_hash_table_foreach (task->urls, surbl_tree_url_callback, ¶m);
+ param->tree);
+ g_hash_table_foreach (task->urls, surbl_tree_url_callback, param);
/* We also need to check and process img URLs */
if (suffix->options & SURBL_OPTION_CHECKIMAGES) {
img->src, strlen (img->src), NULL);
if (url) {
- surbl_tree_url_callback (url, url, ¶m);
+ surbl_tree_url_callback (url, url, param);
msg_debug_surbl ("checked image url %s over %s",
img->src, suffix->suffix);
}
if (lua_type (L, -1) == LUA_TFUNCTION) {
surbl_module_ctx->redirector_cbid = luaL_ref (L, LUA_REGISTRYINDEX);
+ surbl_module_ctx->use_redirector = TRUE;
}
else {
lua_pop (L, 1);