From bc6b7ac2ea6e76f2c533ed281316c9d5fc531583 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sat, 18 Apr 2015 15:07:40 +0100 Subject: [PATCH] Fix lua task processing. --- src/lua/lua_util.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/lua/lua_util.c b/src/lua/lua_util.c index dda51cbd9..aa0b24d68 100644 --- a/src/lua/lua_util.c +++ b/src/lua/lua_util.c @@ -106,7 +106,7 @@ lua_util_config_from_ucl (lua_State *L) if (obj) { cfg = g_malloc0 (sizeof (struct rspamd_config)); rspamd_init_cfg (cfg, FALSE); - + cfg->lua_state = L; cfg->rcl_obj = obj; top = rspamd_rcl_config_init (); @@ -158,6 +158,9 @@ lua_util_process_message (lua_State *L) task->msg.len = mlen; task->fin_callback = lua_util_task_fin; task->fin_arg = &res; + task->resolver = dns_resolver_init (NULL, base, cfg); + task->s = new_async_session (task->task_pool, rspamd_task_fin, + rspamd_task_restore, rspamd_task_free_hard, task); if (rspamd_task_process (task, NULL, message, mlen, NULL, TRUE)) { event_base_loop (base, 0); @@ -167,12 +170,16 @@ lua_util_process_message (lua_State *L) ucl_object_unref (res); } + else { + ucl_object_push_lua (L, rspamd_protocol_write_ucl (task, NULL), + true); + rspamd_task_free_hard (task); + } } else { lua_pushnil (L); } - rspamd_task_free_hard (task); event_base_free (base); } else { -- 2.39.5