aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2022-03-18 16:16:57 +0000
committerMatthew Wild <mwild1@gmail.com>2022-03-18 16:16:57 +0000
commita188ece31ae32f89f945e1064c0a998454cdf936 (patch)
tree1a6c3d6ede801d3c958f5bab5b97efa564ed7bfb /net
parentf278c021e68f508383e8a7b67e5e491614c61def (diff)
downloadprosody-a188ece31ae32f89f945e1064c0a998454cdf936.tar.gz
prosody-a188ece31ae32f89f945e1064c0a998454cdf936.zip
net.connect: When more targets are immediately available, try them after a delay
RFC 8305
Diffstat (limited to 'net')
-rw-r--r--net/connect.lua11
1 files changed, 10 insertions, 1 deletions
diff --git a/net/connect.lua b/net/connect.lua
index 6bc5e6b5..241cc65b 100644
--- a/net/connect.lua
+++ b/net/connect.lua
@@ -1,6 +1,7 @@
local server = require "net.server";
local log = require "util.logger".init("net.connect");
local new_id = require "util.id".short;
+local timer = require "util.timer";
-- TODO #1246 Happy Eyeballs
-- FIXME RFC 6724
@@ -28,7 +29,7 @@ local pending_connection_listeners = {};
local function attempt_connection(p)
p:log("debug", "Checking for targets...");
- p.target_resolver:next(function (conn_type, ip, port, extra)
+ p.target_resolver:next(function (conn_type, ip, port, extra, more_targets_available)
if not conn_type then
-- No more targets to try
p:log("debug", "No more connection targets to try", p.target_resolver.last_error);
@@ -47,6 +48,14 @@ local function attempt_connection(p)
end
p.conns[conn] = true;
pending_connections_map[conn] = p;
+ if more_targets_available then
+ timer.add_task(0.250, function ()
+ if not p.connected then
+ p:log("debug", "Still not connected, making parallel connection attempt...");
+ attempt_connection(p);
+ end
+ end);
+ end
end);
end