From 608509a8b52989f26878fe73620b93049fbd41de Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 25 Jun 2014 15:33:49 +0200 Subject: net.adns: Add missing local declaration --- net/adns.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'net') diff --git a/net/adns.lua b/net/adns.lua index 158747c6..2a3fa8ad 100644 --- a/net/adns.lua +++ b/net/adns.lua @@ -52,6 +52,7 @@ function new_async_socket(sock, resolver) local peername = ""; local listener = {}; local handler = {}; + local err; function listener.onincoming(conn, data) if data then dns.feed(handler, data); -- cgit v1.2.3 From 7ef57da0477d5d0cad42f85c3a3027d35eae0968 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 30 Jun 2014 12:45:53 +0200 Subject: net.dns: Fix duplicated cache insertions by limiting outstanding queries per name to one --- net/dns.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'net') diff --git a/net/dns.lua b/net/dns.lua index cdd949a2..492bd1c5 100644 --- a/net/dns.lua +++ b/net/dns.lua @@ -715,6 +715,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); @@ -735,7 +743,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); -- cgit v1.2.3