aboutsummaryrefslogtreecommitdiffstats
path: root/net/connect.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2018-02-26 15:25:34 +0000
committerMatthew Wild <mwild1@gmail.com>2018-02-26 15:25:34 +0000
commit8b8926d7bbf78a0990ab77881fc9a9e9e79721f7 (patch)
tree62d1fe1cf25168c26a4a2592e6afd29baf5c6093 /net/connect.lua
parent8ab5e4497eeec37d6b03ea25b7080cdbbe03a09c (diff)
downloadprosody-8b8926d7bbf78a0990ab77881fc9a9e9e79721f7.tar.gz
prosody-8b8926d7bbf78a0990ab77881fc9a9e9e79721f7.zip
net.connect: Handle immediate failures of server.addclient
Diffstat (limited to 'net/connect.lua')
-rw-r--r--net/connect.lua7
1 files changed, 6 insertions, 1 deletions
diff --git a/net/connect.lua b/net/connect.lua
index 2aa6c16c..c76d78f3 100644
--- a/net/connect.lua
+++ b/net/connect.lua
@@ -36,7 +36,12 @@ local function attempt_connection(p)
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));
+ local conn, err = server.addclient(ip, port, pending_connection_listeners, p.options.pattern or "*a", p.options.sslctx, conn_type, extra);
+ if not conn then
+ log("debug", "Connection attempt failed immediately: %s", tostring(err));
+ p.last_error = err or "unknown reason";
+ return attempt_connection(p);
+ end
p.conn = conn;
pending_connections_map[conn] = p;
end);