Comparison

net/dns.lua @ 6288:d122420542fb

net.dns: Fix duplicated cache insertions by limiting outstanding queries per name to one
author Kim Alvefur <zash@zash.se>
date Mon, 30 Jun 2014 12:45:53 +0200
parent 5730:411e9e7d8035
child 6289:a29cc79295e6
child 6309:b6f76a52eb36
comparison
equal deleted inserted replaced
6287:a380b09649e6 6288:d122420542fb
713 713
714 714
715 function resolver:query(qname, qtype, qclass) -- - - - - - - - - - -- query 715 function resolver:query(qname, qtype, qclass) -- - - - - - - - - - -- query
716 qname, qtype, qclass = standardize(qname, qtype, qclass) 716 qname, qtype, qclass = standardize(qname, qtype, qclass)
717 717
718 local co = coroutine.running();
719 local q = get(self.wanted, qclass, qtype, qname);
720 if co and q then
721 -- We are already waiting for a reply to an identical query.
722 set(self.wanted, qclass, qtype, qname, co, true);
723 return true;
724 end
725
718 if not self.server then self:adddefaultnameservers(); end 726 if not self.server then self:adddefaultnameservers(); end
719 727
720 local question = encodeQuestion(qname, qtype, qclass); 728 local question = encodeQuestion(qname, qtype, qclass);
721 local peek = self:peek (qname, qtype, qclass); 729 local peek = self:peek (qname, qtype, qclass);
722 if peek then return peek; end 730 if peek then return peek; end
733 -- remember the query 741 -- remember the query
734 self.active[id] = self.active[id] or {}; 742 self.active[id] = self.active[id] or {};
735 self.active[id][question] = o; 743 self.active[id][question] = o;
736 744
737 -- remember which coroutine wants the answer 745 -- remember which coroutine wants the answer
738 local co = coroutine.running();
739 if co then 746 if co then
740 set(self.wanted, qclass, qtype, qname, co, true); 747 set(self.wanted, qclass, qtype, qname, co, true);
741 --set(self.yielded, co, qclass, qtype, qname, true); 748 --set(self.yielded, co, qclass, qtype, qname, true);
742 end 749 end
743 750