Merge 0.9->0.10
authorKim Alvefur <zash@zash.se>
Mon, 30 Jun 2014 11:11:01 +0000 (13:11 +0200)
committerKim Alvefur <zash@zash.se>
Mon, 30 Jun 2014 11:11:01 +0000 (13:11 +0200)
net/adns.lua
net/dns.lua

index 08421f77c579dd8f3e51253ad3fe96194cc33d63..15814fe7a4c5d8240bd1373fbe493f336d5a5436 100644 (file)
@@ -52,6 +52,7 @@ function new_async_socket(sock, resolver)
        local peername = "<unknown>";
        local listener = {};
        local handler = {};
+       local err;
        function listener.onincoming(conn, data)
                if data then
                        dns.feed(handler, data);
index bd5c260ec2f1a638843c662544139e1b2eb6e920..088067ae0530375a1a2c5b4e114d3dec0e48b501 100644 (file)
@@ -722,6 +722,14 @@ end
 function resolver:query(qname, qtype, qclass)    -- - - - - - - - - - -- query
        qname, qtype, qclass = standardize(qname, qtype, qclass)
 
+       local co = coroutine.running();
+       local q = get(self.wanted, qclass, qtype, qname);
+       if co and q then
+               -- We are already waiting for a reply to an identical query.
+               set(self.wanted, qclass, qtype, qname, co, true);
+               return true;
+       end
+
        if not self.server then self:adddefaultnameservers(); end
 
        local question = encodeQuestion(qname, qtype, qclass);
@@ -742,7 +750,6 @@ function resolver:query(qname, qtype, qclass)    -- - - - - - - - - - -- query
        self.active[id][question] = o;
 
        -- remember which coroutine wants the answer
-       local co = coroutine.running();
        if co then
                set(self.wanted, qclass, qtype, qname, co, true);
                --set(self.yielded, co, qclass, qtype, qname, true);