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
commitd3f185272930a58a3ce4f963ec1dffcbf7a5cab2 (patch)
treecbe286c1d64d65e6ca9370734d7e0775114a2559 /net
parentb186a9c3bfb5fdb93a8a0d80d7db8ad2a1587505 (diff)
downloadprosody-d3f185272930a58a3ce4f963ec1dffcbf7a5cab2.tar.gz
prosody-d3f185272930a58a3ce4f963ec1dffcbf7a5cab2.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)