Software /
code /
prosody
Diff
net/dns.lua @ 3955:a096700d23d9
net.dns: resolver:query(): Handle getsocket() failures, and return true on success
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 24 Dec 2010 04:52:13 +0000 |
parent | 3954:6e22b0cf3d72 |
child | 4125:5cf13260edec |
line wrap: on
line diff
--- a/net/dns.lua Fri Dec 24 04:51:34 2010 +0000 +++ b/net/dns.lua Fri Dec 24 04:52:13 2010 +0000 @@ -722,7 +722,10 @@ --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 @@ 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)