aboutsummaryrefslogtreecommitdiffstats
path: root/net/adns.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2009-04-10 10:30:50 +0100
committerMatthew Wild <mwild1@gmail.com>2009-04-10 10:30:50 +0100
commit99e99bdbdae1e1588375ecbebdf81390a2fa75b2 (patch)
tree3185296b2890f6002ec86dfb133fa70af593c036 /net/adns.lua
parentce51ad8d0741391ea8587e24c5f5d60f9be6a20f (diff)
downloadprosody-99e99bdbdae1e1588375ecbebdf81390a2fa75b2.tar.gz
prosody-99e99bdbdae1e1588375ecbebdf81390a2fa75b2.zip
net.adns: Catch errors in DNS response callbacks
Diffstat (limited to 'net/adns.lua')
-rw-r--r--net/adns.lua7
1 files changed, 5 insertions, 2 deletions
diff --git a/net/adns.lua b/net/adns.lua
index cb784d40..fb68ea71 100644
--- a/net/adns.lua
+++ b/net/adns.lua
@@ -3,7 +3,7 @@ local dns = require "net.dns";
local log = require "util.logger".init("adns");
-local coroutine, tostring = coroutine, tostring;
+local coroutine, tostring, pcall = coroutine, tostring, pcall;
module "adns"
@@ -14,7 +14,10 @@ function lookup(handler, qname, qtype, qclass)
dns.query(qname, qtype, qclass);
coroutine.yield(nil); -- Wait for reply
log("debug", "Reply for "..qname.." (%s)", tostring(coroutine.running()));
- handler(dns.peek(qname, qtype, qclass));
+ local ok, err = pcall(handler, dns.peek(qname, qtype, qclass));
+ if not ok then
+ log("debug", "Error in DNS response handler: %s", tostring(err));
+ end
end)();
end