Comparison

net/dns.lua @ 7098:5286e79c6829

Merge 0.9->0.10
author Kim Alvefur <zash@zash.se>
date Fri, 22 Jan 2016 14:49:05 +0100
parent 7061:eda0feeaf759
parent 7093:388281be2bc7
child 7322:addf60d25356
comparison
equal deleted inserted replaced
7090:7aa37d70944b 7098:5286e79c6829
752 752
753 -- remember the query 753 -- remember the query
754 self.active[id] = self.active[id] or {}; 754 self.active[id] = self.active[id] or {};
755 self.active[id][question] = o; 755 self.active[id][question] = o;
756 756
757 local conn, err = self:getsocket(o.server)
758 if not conn then
759 return nil, err;
760 end
761 conn:send (o.packet)
762
757 -- remember which coroutine wants the answer 763 -- remember which coroutine wants the answer
758 if co then 764 if co then
759 set(self.wanted, qclass, qtype, qname, co, true); 765 set(self.wanted, qclass, qtype, qname, co, true);
760 end 766 end
761 767
762 local conn, err = self:getsocket(o.server)
763 if not conn then
764 return nil, err;
765 end
766 conn:send (o.packet)
767
768 if timer and self.timeout then 768 if timer and self.timeout then
769 local num_servers = #self.server; 769 local num_servers = #self.server;
770 local i = 1; 770 local i = 1;
771 timer.add_task(self.timeout, function () 771 timer.add_task(self.timeout, function ()
772 if get(self.wanted, qclass, qtype, qname, co) then 772 if get(self.wanted, qclass, qtype, qname, co) then
859 end 859 end
860 860
861 -- retire the query 861 -- retire the query
862 local queries = self.active[response.header.id]; 862 local queries = self.active[response.header.id];
863 queries[response.question.raw] = nil; 863 queries[response.question.raw] = nil;
864 864
865 if not next(queries) then self.active[response.header.id] = nil; end 865 if not next(queries) then self.active[response.header.id] = nil; end
866 if not next(self.active) then self:closeall(); end 866 if not next(self.active) then self:closeall(); end
867 867
868 -- was the query on the wanted list? 868 -- was the query on the wanted list?
869 local q = response.question[1]; 869 local q = response.question[1];
873 if coroutine.status(co) == "suspended" then coroutine.resume(co); end 873 if coroutine.status(co) == "suspended" then coroutine.resume(co); end
874 end 874 end
875 set(self.wanted, q.class, q.type, q.name, nil); 875 set(self.wanted, q.class, q.type, q.name, nil);
876 end 876 end
877 end 877 end
878 878
879 end 879 end
880 end 880 end
881 end 881 end
882 882
883 return response; 883 return response;