aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua_worker.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2012-08-13 20:40:50 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2012-08-13 20:40:50 +0400
commitcd85daafe383de85701d726461e3e464f7f70249 (patch)
tree5216e42fc3ae75d08ac653870b3e82f7f482ea6c /src/lua_worker.c
parentac13c4d304d190ead195f12a2db74ae08a91ed6b (diff)
downloadrspamd-cd85daafe383de85701d726461e3e464f7f70249.tar.gz
rspamd-cd85daafe383de85701d726461e3e464f7f70249.zip
* Add DNS resolver lua bindings.
Make lua http library working without task object. Fix a problem with resolver in lua_worker. Added some utility functions to lua api.
Diffstat (limited to 'src/lua_worker.c')
-rw-r--r--src/lua_worker.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/lua_worker.c b/src/lua_worker.c
index b7daf7ce7..51066624b 100644
--- a/src/lua_worker.c
+++ b/src/lua_worker.c
@@ -225,9 +225,12 @@ static int
lua_worker_get_resolver (lua_State *L)
{
struct rspamd_lua_worker_ctx *ctx = lua_check_lua_worker (L);
+ struct rspamd_dns_resolver **presolver;
if (ctx) {
- /* XXX: implement resolver API */
+ presolver = lua_newuserdata (L, sizeof (gpointer));
+ lua_setclass (L, "rspamd{resolver}", -1);
+ *presolver = ctx->resolver;
}
else {
lua_pushnil (L);
@@ -460,6 +463,8 @@ start_lua_worker (struct rspamd_worker *worker)
event_base_set (ctx->ev_base, &worker->bind_ev);
event_add (&worker->bind_ev, NULL);
+ ctx->resolver = dns_resolver_init (ctx->ev_base, worker->srv->cfg);
+
/* Open worker's lib */
luaopen_lua_worker (L);
@@ -489,7 +494,6 @@ start_lua_worker (struct rspamd_worker *worker)
/* Maps events */
start_map_watch (ctx->ev_base);
- ctx->resolver = dns_resolver_init (ctx->ev_base, worker->srv->cfg);
event_base_loop (ctx->ev_base, 0);
luaL_unref (L, LUA_REGISTRYINDEX, ctx->cbref_accept);