aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2010-12-24 04:52:13 +0000
committerMatthew Wild <mwild1@gmail.com>2010-12-24 04:52:13 +0000
commit1f2665ff51d61aec7e91294b199a9acc8f845445 (patch)
tree0339a9cb6037d2e6c9eed5cf5d2c4c43f57d7ee6 /net
parent24b4c74559e467dda5046253b8df68c77e723670 (diff)
downloadprosody-1f2665ff51d61aec7e91294b199a9acc8f845445.tar.gz
prosody-1f2665ff51d61aec7e91294b199a9acc8f845445.zip
net.dns: resolver:query(): Handle getsocket() failures, and return true on success
Diffstat (limited to 'net')
-rw-r--r--net/dns.lua19
1 files changed, 12 insertions, 7 deletions
diff --git a/net/dns.lua b/net/dns.lua
index 0101daa3..61fb62e8 100644
--- a/net/dns.lua
+++ b/net/dns.lua
@@ -722,7 +722,10 @@ function resolver:query(qname, qtype, qclass) -- - - - - - - - - - -- query
--set(self.yielded, co, qclass, qtype, qname, true);
end
- local conn = self:getsocket(o.server)
+ local conn, err = self:getsocket(o.server)
+ if not conn then
+ return nil, err;
+ end
conn:send (o.packet)
if timer and self.timeout then
@@ -734,16 +737,18 @@ function resolver:query(qname, qtype, qclass) -- - - - - - - - - - -- query
i = i + 1;
self:servfail(conn);
o.server = self.best_server;
- conn = self:getsocket(o.server);
- conn:send(o.packet);
- return self.timeout;
- else
- -- Tried everything, failed
- self:cancel(qclass, qtype, qname, co, true);
+ conn, err = self:getsocket(o.server);
+ if conn then
+ conn:send(o.packet);
+ return self.timeout;
+ end
end
+ -- Tried everything, failed
+ self:cancel(qclass, qtype, qname, co, true);
end
end)
end
+ return true;
end
function resolver:servfail(sock)