aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2018-02-26 15:21:27 +0000
committerMatthew Wild <mwild1@gmail.com>2018-02-26 15:21:27 +0000
commit95e2e410db8c631c4c8bef4bf7d1082c295e533d (patch)
treeea95d9e43625325c6b2513fc4614fa4464960b19
parentc394f11359d7670f675f1ab525ae1fc2aec0570a (diff)
downloadprosody-95e2e410db8c631c4c8bef4bf7d1082c295e533d.tar.gz
prosody-95e2e410db8c631c4c8bef4bf7d1082c295e533d.zip
net.connect: Handle case when resolver runs out of targets
-rw-r--r--net/connect.lua8
1 files changed, 8 insertions, 0 deletions
diff --git a/net/connect.lua b/net/connect.lua
index aa6e622b..2aa6c16c 100644
--- a/net/connect.lua
+++ b/net/connect.lua
@@ -27,6 +27,14 @@ local function attempt_connection(p)
p.conn = nil;
end
p.target_resolver:next(function (conn_type, ip, port, extra)
+ if not conn_type then
+ -- No more targets to try
+ p:log("debug", "No more connection targets to try");
+ if p.listeners.onfail then
+ p.listeners.onfail(p.data, p.last_error or "unable to connect to service");
+ end
+ return;
+ end
p:log("debug", "Next target to try is %s:%d", ip, port);
local conn = assert(server.addclient(ip, port, pending_connection_listeners, p.options.pattern or "*a", p.options.sslctx, conn_type, extra));
p.conn = conn;