diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-10-25 17:24:18 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-10-25 17:24:18 +0100 |
commit | b67fe9273c2ae05fa0e6de6f96f3d3ff22553d02 (patch) | |
tree | d2acb0542f172905487565da7c2cd76d358366c2 | |
parent | 880883e61a237dd8c7bcfa5bb382c938bb1256f6 (diff) | |
download | rspamd-b67fe9273c2ae05fa0e6de6f96f3d3ff22553d02.tar.gz rspamd-b67fe9273c2ae05fa0e6de6f96f3d3ff22553d02.zip |
[Minor] Try harder to track DNS based chaining
-rw-r--r-- | src/libserver/dns.c | 5 | ||||
-rw-r--r-- | src/lua/lua_dns_resolver.c | 19 |
2 files changed, 23 insertions, 1 deletions
diff --git a/src/libserver/dns.c b/src/libserver/dns.c index b0bde6bce..358bf7dca 100644 --- a/src/libserver/dns.c +++ b/src/libserver/dns.c @@ -60,6 +60,10 @@ rspamd_dns_fin_cb (gpointer arg) { struct rspamd_dns_request_ud *reqdata = (struct rspamd_dns_request_ud *)arg; + if (reqdata->item) { + rspamd_symbols_cache_set_cur_item (reqdata->task, reqdata->item); + } + if (reqdata->reply) { reqdata->cb (reqdata->reply, reqdata->ud); } @@ -164,6 +168,7 @@ make_dns_request (struct rspamd_dns_resolver *resolver, if (pool == NULL) { g_free (reqdata); } + return NULL; } diff --git a/src/lua/lua_dns_resolver.c b/src/lua/lua_dns_resolver.c index d00aaa6a2..c95d7bbba 100644 --- a/src/lua/lua_dns_resolver.c +++ b/src/lua/lua_dns_resolver.c @@ -183,6 +183,11 @@ lua_dns_resolver_callback (struct rdns_reply *reply, gpointer arg) lua_pushboolean (L, reply->authenticated); + if (cd->item) { + /* We also need to restore the item in case there are some chains */ + rspamd_symbols_cache_set_cur_item (cd->task, cd->item); + } + if (lua_pcall (L, 6, 0, err_idx) != 0) { tb = lua_touserdata (L, -1); @@ -438,6 +443,13 @@ lua_dns_resolver_resolve_common (lua_State *L, } } else { + /* Fail-safety as this function can, in theory, call + * lua_dns_resolver_callback without switching to the event loop + */ + if (cbdata->item) { + rspamd_symcache_item_async_inc (task, cbdata->item); + } + if (forced) { ret = make_dns_request_task_forced (task, lua_dns_resolver_callback, @@ -461,9 +473,14 @@ lua_dns_resolver_resolve_common (lua_State *L, } /* callback was set up */ lua_pushboolean (L, TRUE); - } else { + } + else { lua_pushnil (L); } + + if (cbdata->item) { + rspamd_symcache_item_async_dec_check (task, cbdata->item); + } } } else { |