diff options
author | Matthew Wild <mwild1@gmail.com> | 2018-02-26 15:21:27 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2018-02-26 15:21:27 +0000 |
commit | 95e2e410db8c631c4c8bef4bf7d1082c295e533d (patch) | |
tree | ea95d9e43625325c6b2513fc4614fa4464960b19 | |
parent | c394f11359d7670f675f1ab525ae1fc2aec0570a (diff) | |
download | prosody-95e2e410db8c631c4c8bef4bf7d1082c295e533d.tar.gz prosody-95e2e410db8c631c4c8bef4bf7d1082c295e533d.zip |
net.connect: Handle case when resolver runs out of targets
-rw-r--r-- | net/connect.lua | 8 |
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; |