Software /
code /
prosody
Comparison
net/resolvers/service.lua @ 10650:324a0c7d1c6a
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.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 16 Feb 2020 23:48:31 +0100 |
parent | 10484:b13a31cea7d9 |
child | 10970:4603697aee50 |
comparison
equal
deleted
inserted
replaced
10649:228277be4a28 | 10650:324a0c7d1c6a |
---|---|
12 | 12 |
13 -- Find the next target to connect to, and | 13 -- Find the next target to connect to, and |
14 -- pass it to cb() | 14 -- pass it to cb() |
15 function methods:next(cb) | 15 function methods:next(cb) |
16 if self.targets then | 16 if self.targets then |
17 if #self.targets == 0 then | 17 if not self.resolver then |
18 cb(nil); | 18 if #self.targets == 0 then |
19 return; | 19 cb(nil); |
20 return; | |
21 end | |
22 local next_target = table.remove(self.targets, 1); | |
23 self.resolver = basic.new(unpack(next_target, 1, 4)); | |
20 end | 24 end |
21 local next_target = table.remove(self.targets, 1); | |
22 self.resolver = basic.new(unpack(next_target, 1, 4)); | |
23 self.resolver:next(function (...) | 25 self.resolver:next(function (...) |
24 if ... == nil then | 26 if ... == nil then |
27 self.resolver = nil; | |
25 self:next(cb); | 28 self:next(cb); |
26 else | 29 else |
27 cb(...); | 30 cb(...); |
28 end | 31 end |
29 end); | 32 end); |