Skip to content

Commit

Permalink
[resolver] remove parallel dns query
Browse files Browse the repository at this point in the history
lets delegate this work to a dns resolver like dnsmasq

it was broken and sometimes would return a string "killed" instead of
table with answers that would count as valid answer
  • Loading branch information
mikz committed Mar 17, 2017
1 parent 1aa004d commit 9ce62de
Showing 1 changed file with 1 addition and 33 deletions.
34 changes: 1 addition & 33 deletions apicast/src/resty/resolver/dns_client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,37 +62,6 @@ local function query(resolver, qname, opts, nameserver)
return resolver:query(qname, opts)
end

local function parallel_query(resolvers, qname, opts)
local threads = {}
local n = #resolvers

if n < 1 then
return nil, 'no resolvers'
end

for i=1, n do
insert(threads, th_spawn(query, resolvers[i].resolver, qname, opts, resolvers[i].nameserver))
end

local answers, err

do
local found, ok
local i=1
repeat
ok, answers, err = th_wait(unpack(threads))
i = i + 1
found = ok and answers and not answers.errcode and not err
until found or i > n
end

for i=1, n do
th_kill(threads[i])
end

return answers, err
end

local function serial_query(resolvers, qname, opts)
local answers, err

Expand All @@ -114,8 +83,7 @@ function _M.query(self, qname, opts)
resolvers = self:init_resolvers()
end

-- this is here so you can try the other one when suspicous something is wrong
return (parallel_query or serial_query)(resolvers, qname, opts)
return serial_query(resolvers, qname, opts)
end

return _M

0 comments on commit 9ce62de

Please sign in to comment.