aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2010-12-24 04:52:40 +0000
committerMatthew Wild <mwild1@gmail.com>2010-12-24 04:52:40 +0000
commitb1a22d59e455f22151650c88d622ee3a2710a9ca (patch)
tree9d0a93bd9e1f6807f1d17a9f3f6ed5fbf2ea8107 /net
parentd3f185272930a58a3ce4f963ec1dffcbf7a5cab2 (diff)
downloadprosody-b1a22d59e455f22151650c88d622ee3a2710a9ca.tar.gz
prosody-b1a22d59e455f22151650c88d622ee3a2710a9ca.zip
net.adns: Handle dns.query() failures, and pass error to handler
Diffstat (limited to 'net')
-rw-r--r--net/adns.lua15
1 files changed, 11 insertions, 4 deletions
diff --git a/net/adns.lua b/net/adns.lua
index d0151c8c..2f7b6804 100644
--- a/net/adns.lua
+++ b/net/adns.lua
@@ -26,10 +26,17 @@ function lookup(handler, qname, qtype, qclass)
return;
end
log("debug", "Records for %s not in cache, sending query (%s)...", qname, tostring(coroutine.running()));
- dns.query(qname, qtype, qclass);
- coroutine.yield({ qclass or "IN", qtype or "A", qname, coroutine.running()}); -- Wait for reply
- log("debug", "Reply for %s (%s)", qname, tostring(coroutine.running()));
- local ok, err = pcall(handler, dns.peek(qname, qtype, qclass));
+ local ok, err = dns.query(qname, qtype, qclass);
+ if ok then
+ coroutine.yield({ qclass or "IN", qtype or "A", qname, coroutine.running()}); -- Wait for reply
+ log("debug", "Reply for %s (%s)", qname, tostring(coroutine.running()));
+ end
+ if ok then
+ ok, err = pcall(handler, dns.peek(qname, qtype, qclass));
+ else
+ log("error", "Error sending DNS query: %s", err);
+ ok, err = pcall(handler, nil, err);
+ end
if not ok then
log("error", "Error in DNS response handler: %s", tostring(err));
end