Merge 0.10->trunk
authorKim Alvefur <zash@zash.se>
Mon, 30 Jun 2014 13:12:16 +0200
changeset 6290 54e748acc07a
parent 6286 ec6e8d5a3fd3 (current diff)
parent 6289 a29cc79295e6 (diff)
child 6304 ace08821e4ee
Merge 0.10->trunk
--- a/net/adns.lua	Wed Jun 25 12:15:00 2014 -0400
+++ b/net/adns.lua	Mon Jun 30 13:12:16 2014 +0200
@@ -52,6 +52,7 @@
 	local peername = "<unknown>";
 	local listener = {};
 	local handler = {};
+	local err;
 	function listener.onincoming(conn, data)
 		if data then
 			dns.feed(handler, data);
--- a/net/dns.lua	Wed Jun 25 12:15:00 2014 -0400
+++ b/net/dns.lua	Mon Jun 30 13:12:16 2014 +0200
@@ -722,6 +722,14 @@
 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 @@
 	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);