Skip to content

Commit

Permalink
Merge pull request #311 from 3scale/remove-parallel-query
Browse files Browse the repository at this point in the history
[resolver] remove parallel dns query
  • Loading branch information
mikz authored Mar 17, 2017
2 parents 1aa004d + 2d63f47 commit d4c6697
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 37 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Removed

- Removed support for sending Request logs [PR #296](https://github.com/3scale/apicast/pull/296)
- Support for parallel DNS query [PR #311](https://github.com/3scale/apicast/pull/311)

### Known Issues

Expand Down
38 changes: 1 addition & 37 deletions apicast/src/resty/resolver/dns_client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ local resty_resolver = require 'resty.dns.resolver'

local setmetatable = setmetatable
local insert = table.insert
local th_spawn = ngx.thread.spawn
local th_wait = ngx.thread.wait
local th_kill = ngx.thread.kill
local unpack = unpack

local _M = {
_VERSION = '0.1'
Expand Down Expand Up @@ -62,37 +58,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 +79,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 d4c6697

Please sign in to comment.