aboutsummaryrefslogtreecommitdiffstats
path: root/net/dns.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2014-06-30 12:45:53 +0200
committerKim Alvefur <zash@zash.se>2014-06-30 12:45:53 +0200
commite0311c41dabee36bc352b981ad3735c9ed76c4ec (patch)
tree7e6304e340020f8114d8707e07f3af5ee8a476ba /net/dns.lua
parentdba28352cd74515c1bbe0c60fdfcf174d2b66511 (diff)
downloadprosody-e0311c41dabee36bc352b981ad3735c9ed76c4ec.tar.gz
prosody-e0311c41dabee36bc352b981ad3735c9ed76c4ec.zip
net.dns: Fix duplicated cache insertions by limiting outstanding queries per name to one
Diffstat (limited to 'net/dns.lua')
-rw-r--r--net/dns.lua9
1 files changed, 8 insertions, 1 deletions
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);