Software /
code /
prosody
Comparison
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 |
comparison
equal
deleted
inserted
replaced
3954:6e22b0cf3d72 | 3955:a096700d23d9 |
---|---|
720 if co then | 720 if co then |
721 set(self.wanted, qclass, qtype, qname, co, true); | 721 set(self.wanted, qclass, qtype, qname, co, true); |
722 --set(self.yielded, co, qclass, qtype, qname, true); | 722 --set(self.yielded, co, qclass, qtype, qname, true); |
723 end | 723 end |
724 | 724 |
725 local conn = self:getsocket(o.server) | 725 local conn, err = self:getsocket(o.server) |
726 if not conn then | |
727 return nil, err; | |
728 end | |
726 conn:send (o.packet) | 729 conn:send (o.packet) |
727 | 730 |
728 if timer and self.timeout then | 731 if timer and self.timeout then |
729 local num_servers = #self.server; | 732 local num_servers = #self.server; |
730 local i = 1; | 733 local i = 1; |
732 if get(self.wanted, qclass, qtype, qname, co) then | 735 if get(self.wanted, qclass, qtype, qname, co) then |
733 if i < num_servers then | 736 if i < num_servers then |
734 i = i + 1; | 737 i = i + 1; |
735 self:servfail(conn); | 738 self:servfail(conn); |
736 o.server = self.best_server; | 739 o.server = self.best_server; |
737 conn = self:getsocket(o.server); | 740 conn, err = self:getsocket(o.server); |
738 conn:send(o.packet); | 741 if conn then |
739 return self.timeout; | 742 conn:send(o.packet); |
740 else | 743 return self.timeout; |
741 -- Tried everything, failed | 744 end |
742 self:cancel(qclass, qtype, qname, co, true); | |
743 end | 745 end |
746 -- Tried everything, failed | |
747 self:cancel(qclass, qtype, qname, co, true); | |
744 end | 748 end |
745 end) | 749 end) |
746 end | 750 end |
751 return true; | |
747 end | 752 end |
748 | 753 |
749 function resolver:servfail(sock) | 754 function resolver:servfail(sock) |
750 -- Resend all queries for this server | 755 -- Resend all queries for this server |
751 | 756 |