Software /
code /
prosody
Comparison
net/dns.lua @ 6508:4a28b8320d7f
net.dns: Return new socket from servfail
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 30 Oct 2014 12:10:15 +0100 |
parent | 6463:460584257cc9 |
child | 6509:7cb69eba3e95 |
comparison
equal
deleted
inserted
replaced
6507:84ca02c6a47e | 6508:4a28b8320d7f |
---|---|
785 -- Resend all queries for this server | 785 -- Resend all queries for this server |
786 | 786 |
787 local num = self.socketset[sock] | 787 local num = self.socketset[sock] |
788 | 788 |
789 -- Socket is dead now | 789 -- Socket is dead now |
790 self:voidsocket(sock); | 790 sock = self:voidsocket(sock); |
791 | 791 |
792 -- Find all requests to the down server, and retry on the next server | 792 -- Find all requests to the down server, and retry on the next server |
793 self.time = socket.gettime(); | 793 self.time = socket.gettime(); |
794 for id,queries in pairs(self.active) do | 794 for id,queries in pairs(self.active) do |
795 for question,o in pairs(queries) do | 795 for question,o in pairs(queries) do |
802 o.retries = (o.retries or 0) + 1; | 802 o.retries = (o.retries or 0) + 1; |
803 if o.retries >= #self.server then | 803 if o.retries >= #self.server then |
804 --print('timeout'); | 804 --print('timeout'); |
805 queries[question] = nil; | 805 queries[question] = nil; |
806 else | 806 else |
807 local _a = self:getsocket(o.server); | 807 sock = self:getsocket(o.server); |
808 if _a then _a:send(o.packet); end | 808 if sock then sock:send(o.packet); end |
809 end | 809 end |
810 end | 810 end |
811 end | 811 end |
812 if next(queries) == nil then | 812 if next(queries) == nil then |
813 self.active[id] = nil; | 813 self.active[id] = nil; |
819 if self.best_server > #self.server then | 819 if self.best_server > #self.server then |
820 -- Exhausted all servers, try first again | 820 -- Exhausted all servers, try first again |
821 self.best_server = 1; | 821 self.best_server = 1; |
822 end | 822 end |
823 end | 823 end |
824 return sock; | |
824 end | 825 end |
825 | 826 |
826 function resolver:settimeout(seconds) | 827 function resolver:settimeout(seconds) |
827 self.timeout = seconds; | 828 self.timeout = seconds; |
828 end | 829 end |