diff options
author | Kim Alvefur <zash@zash.se> | 2020-02-16 23:48:31 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2020-02-16 23:48:31 +0100 |
commit | dce92c437ae10cc79abacc7960482065299fd230 (patch) | |
tree | a3cec3cb565eeb266766b0905ae1943f7375722d /net | |
parent | 61b6b340b1fb3c3bfc01e3cb22058cc8a2c52064 (diff) | |
download | prosody-dce92c437ae10cc79abacc7960482065299fd230.tar.gz prosody-dce92c437ae10cc79abacc7960482065299fd230.zip |
net.resolvers.service: Fix resolving of targets with multiple IPs
Each basic resolver was only used once and not kept around to try any
IP addresses but the first one found.
Diffstat (limited to 'net')
-rw-r--r-- | net/resolvers/service.lua | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/net/resolvers/service.lua b/net/resolvers/service.lua index b4300d08..f74338db 100644 --- a/net/resolvers/service.lua +++ b/net/resolvers/service.lua @@ -14,14 +14,17 @@ local resolver_mt = { __index = methods }; -- pass it to cb() function methods:next(cb) if self.targets then - if #self.targets == 0 then - cb(nil); - return; + if not self.resolver then + if #self.targets == 0 then + cb(nil); + return; + end + local next_target = table.remove(self.targets, 1); + self.resolver = basic.new(unpack(next_target, 1, 4)); end - local next_target = table.remove(self.targets, 1); - self.resolver = basic.new(unpack(next_target, 1, 4)); self.resolver:next(function (...) if ... == nil then + self.resolver = nil; self:next(cb); else cb(...); |