Software /
code /
prosody
Annotate
net/connect.lua @ 13652:a08065207ef0
net.server_epoll: Call :shutdown() on TLS sockets when supported
Comment from Matthew:
This fixes a potential issue where the Prosody process gets blocked on sockets
waiting for them to close. Unlike non-TLS sockets, closing a TLS socket sends
layer 7 data, and this can cause problems for sockets which are in the process
of being cleaned up.
This depends on LuaSec changes which are not yet upstream.
From Martijn's original email:
So first my analysis of luasec. in ssl.c the socket is put into blocking
mode right before calling SSL_shutdown() inside meth_destroy(). My best
guess to why this is is because meth_destroy is linked to the __close
and __gc methods, which can't exactly be called multiple times and
luasec does want to make sure that a tls session is shutdown as clean
as possible.
I can't say I disagree with this reasoning and don't want to change this
behaviour. My solution to this without changing the current behaviour is
to introduce a shutdown() method. I am aware that this overlaps in a
conflicting way with tcp's shutdown method, but it stays close to the
OpenSSL name. This method calls SSL_shutdown() in the current
(non)blocking mode of the underlying socket and returns a boolean
whether or not the shutdown is completed (matching SSL_shutdown()'s 0
or 1 return values), and returns the familiar ssl_ioerror() strings on
error with a false for completion. This error can then be used to
determine if we have wantread/wantwrite to finalize things. Once
meth_shutdown() has been called once a shutdown flag will be set, which
indicates to meth_destroy() that the SSL_shutdown() has been handled
by the application and it shouldn't be needed to set the socket to
blocking mode. I've left the SSL_shutdown() call in the
LSEC_STATE_CONNECTED to prevent TOCTOU if the application reaches a
timeout for the shutdown code, which might allow SSL_shutdown() to
clean up anyway at the last possible moment.
Another thing I've changed to luasec is the call to socket_setblocking()
right before calling close(2) in socket_destroy() in usocket.c.
According to the latest POSIX[0]:
Note that the requirement for close() on a socket to block for up to
the current linger interval is not conditional on the O_NONBLOCK
setting.
Which I read to mean that removing O_NONBLOCK on the socket before close
doesn't impact the behaviour and only causes noise in system call
tracers. I didn't touch the windows bits of this, since I don't do
windows.
For the prosody side of things I've made the TLS shutdown bits resemble
interface:onwritable(), and put it under a combined guard of self._tls
and self.conn.shutdown. The self._tls bit is there to prevent getting
stuck on this condition, and self.conn.shutdown is there to prevent the
code being called by instances where the patched luasec isn't deployed.
The destroy() method can be called from various places and is read by
me as the "we give up" error path. To accommodate for these unexpected
entrypoints I've added a single call to self.conn:shutdown() to prevent
the socket being put into blocking mode. I have no expectations that
there is any other use here. Same as previous, the self.conn.shutdown
check is there to make sure it's not called on unpatched luasec
deployments and self._tls is there to make sure we don't call shutdown()
on tcp sockets.
I wouldn't recommend logging of the conn:shutdown() error inside
close(), since a lot of clients simply close the connection before
SSL_shutdown() is done.
author | Martijn van Duren <martijn@openbsd.org> |
---|---|
date | Thu, 06 Feb 2025 15:04:38 +0000 |
parent | 12974:ba409c67353b |
rev | line source |
---|---|
12974
ba409c67353b
net: Prefix module imports with prosody namespace
Kim Alvefur <zash@zash.se>
parents:
12639
diff
changeset
|
1 local server = require "prosody.net.server"; |
ba409c67353b
net: Prefix module imports with prosody namespace
Kim Alvefur <zash@zash.se>
parents:
12639
diff
changeset
|
2 local log = require "prosody.util.logger".init("net.connect"); |
ba409c67353b
net: Prefix module imports with prosody namespace
Kim Alvefur <zash@zash.se>
parents:
12639
diff
changeset
|
3 local new_id = require "prosody.util.id".short; |
ba409c67353b
net: Prefix module imports with prosody namespace
Kim Alvefur <zash@zash.se>
parents:
12639
diff
changeset
|
4 local timer = require "prosody.util.timer"; |
8531
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5 |
10485
913276ba0c47
net.connect: Mention RFC 6724 regression
Kim Alvefur <zash@zash.se>
parents:
10484
diff
changeset
|
6 -- FIXME RFC 6724 |
10452
fa11070c2cd7
net.connect: Add some TODO comments
Kim Alvefur <zash@zash.se>
parents:
10112
diff
changeset
|
7 -- FIXME Error propagation from resolvers doesn't work |
10484
b13a31cea7d9
net.connect: Add some TODOs and FIXMEs
Kim Alvefur <zash@zash.se>
parents:
10452
diff
changeset
|
8 -- FIXME #1428 Reuse DNS resolver object between service and basic resolver |
b13a31cea7d9
net.connect: Add some TODOs and FIXMEs
Kim Alvefur <zash@zash.se>
parents:
10452
diff
changeset
|
9 -- FIXME #1429 Close DNS resolver object when done |
10452
fa11070c2cd7
net.connect: Add some TODO comments
Kim Alvefur <zash@zash.se>
parents:
10112
diff
changeset
|
10 |
8531
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
11 local pending_connection_methods = {}; |
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
12 local pending_connection_mt = { |
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
13 __name = "pending_connection"; |
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
14 __index = pending_connection_methods; |
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
15 __tostring = function (p) |
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
16 return "<pending connection "..p.id.." to "..tostring(p.target_resolver.hostname)..">"; |
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
17 end; |
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
18 }; |
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
19 |
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
20 function pending_connection_methods:log(level, message, ...) |
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
21 log(level, "[pending connection %s] "..message, self.id, ...); |
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
22 end |
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
23 |
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
24 -- pending_connections_map[conn] = pending_connection |
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
25 local pending_connections_map = {}; |
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
26 |
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
27 local pending_connection_listeners = {}; |
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
28 |
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
29 local function attempt_connection(p) |
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
30 p:log("debug", "Checking for targets..."); |
12412
18a3a6218100
net.connect: When more targets are immediately available, try them after a delay
Matthew Wild <mwild1@gmail.com>
parents:
12411
diff
changeset
|
31 p.target_resolver:next(function (conn_type, ip, port, extra, more_targets_available) |
8547
5e9c87376891
net.connect: Handle case when resolver runs out of targets
Matthew Wild <mwild1@gmail.com>
parents:
8546
diff
changeset
|
32 if not conn_type then |
5e9c87376891
net.connect: Handle case when resolver runs out of targets
Matthew Wild <mwild1@gmail.com>
parents:
8546
diff
changeset
|
33 -- No more targets to try |
11901
26406ce35e20
net.connect: Propagate last error message from resolvers
Kim Alvefur <zash@zash.se>
parents:
10945
diff
changeset
|
34 p:log("debug", "No more connection targets to try", p.target_resolver.last_error); |
12425
eabcc3ae22e9
net.connect: Improve handling of failure when attempts are still pending
Matthew Wild <mwild1@gmail.com>
parents:
12412
diff
changeset
|
35 if next(p.conns) == nil then |
eabcc3ae22e9
net.connect: Improve handling of failure when attempts are still pending
Matthew Wild <mwild1@gmail.com>
parents:
12412
diff
changeset
|
36 p:log("debug", "No more targets, no pending connections. Connection failed."); |
eabcc3ae22e9
net.connect: Improve handling of failure when attempts are still pending
Matthew Wild <mwild1@gmail.com>
parents:
12412
diff
changeset
|
37 if p.listeners.onfail then |
eabcc3ae22e9
net.connect: Improve handling of failure when attempts are still pending
Matthew Wild <mwild1@gmail.com>
parents:
12412
diff
changeset
|
38 p.listeners.onfail(p.data, p.last_error or p.target_resolver.last_error or "unable to resolve service"); |
eabcc3ae22e9
net.connect: Improve handling of failure when attempts are still pending
Matthew Wild <mwild1@gmail.com>
parents:
12412
diff
changeset
|
39 end |
eabcc3ae22e9
net.connect: Improve handling of failure when attempts are still pending
Matthew Wild <mwild1@gmail.com>
parents:
12412
diff
changeset
|
40 else |
eabcc3ae22e9
net.connect: Improve handling of failure when attempts are still pending
Matthew Wild <mwild1@gmail.com>
parents:
12412
diff
changeset
|
41 p:log("debug", "One or more connection attempts are still pending. Waiting for now."); |
8547
5e9c87376891
net.connect: Handle case when resolver runs out of targets
Matthew Wild <mwild1@gmail.com>
parents:
8546
diff
changeset
|
42 end |
5e9c87376891
net.connect: Handle case when resolver runs out of targets
Matthew Wild <mwild1@gmail.com>
parents:
8546
diff
changeset
|
43 return; |
5e9c87376891
net.connect: Handle case when resolver runs out of targets
Matthew Wild <mwild1@gmail.com>
parents:
8546
diff
changeset
|
44 end |
8531
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
45 p:log("debug", "Next target to try is %s:%d", ip, port); |
12205
a2e6605303fa
net.connect: Allow passing TLS context from resolver
Kim Alvefur <zash@zash.se>
parents:
11903
diff
changeset
|
46 local conn, err = server.addclient(ip, port, pending_connection_listeners, p.options.pattern or "*a", |
a2e6605303fa
net.connect: Allow passing TLS context from resolver
Kim Alvefur <zash@zash.se>
parents:
11903
diff
changeset
|
47 extra and extra.sslctx or p.options.sslctx, conn_type, extra); |
8548
162f75ac2693
net.connect: Handle immediate failures of server.addclient
Matthew Wild <mwild1@gmail.com>
parents:
8547
diff
changeset
|
48 if not conn then |
10112
b327f2870382
net.*: Remove tostring call from logging
Kim Alvefur <zash@zash.se>
parents:
9387
diff
changeset
|
49 log("debug", "Connection attempt failed immediately: %s", err); |
8548
162f75ac2693
net.connect: Handle immediate failures of server.addclient
Matthew Wild <mwild1@gmail.com>
parents:
8547
diff
changeset
|
50 p.last_error = err or "unknown reason"; |
162f75ac2693
net.connect: Handle immediate failures of server.addclient
Matthew Wild <mwild1@gmail.com>
parents:
8547
diff
changeset
|
51 return attempt_connection(p); |
162f75ac2693
net.connect: Handle immediate failures of server.addclient
Matthew Wild <mwild1@gmail.com>
parents:
8547
diff
changeset
|
52 end |
12411
e132a4279914
net.connect: Support for multiple pending connection attempts
Matthew Wild <mwild1@gmail.com>
parents:
12205
diff
changeset
|
53 p.conns[conn] = true; |
8531
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
54 pending_connections_map[conn] = p; |
12412
18a3a6218100
net.connect: When more targets are immediately available, try them after a delay
Matthew Wild <mwild1@gmail.com>
parents:
12411
diff
changeset
|
55 if more_targets_available then |
18a3a6218100
net.connect: When more targets are immediately available, try them after a delay
Matthew Wild <mwild1@gmail.com>
parents:
12411
diff
changeset
|
56 timer.add_task(0.250, function () |
18a3a6218100
net.connect: When more targets are immediately available, try them after a delay
Matthew Wild <mwild1@gmail.com>
parents:
12411
diff
changeset
|
57 if not p.connected then |
18a3a6218100
net.connect: When more targets are immediately available, try them after a delay
Matthew Wild <mwild1@gmail.com>
parents:
12411
diff
changeset
|
58 p:log("debug", "Still not connected, making parallel connection attempt..."); |
18a3a6218100
net.connect: When more targets are immediately available, try them after a delay
Matthew Wild <mwild1@gmail.com>
parents:
12411
diff
changeset
|
59 attempt_connection(p); |
18a3a6218100
net.connect: When more targets are immediately available, try them after a delay
Matthew Wild <mwild1@gmail.com>
parents:
12411
diff
changeset
|
60 end |
18a3a6218100
net.connect: When more targets are immediately available, try them after a delay
Matthew Wild <mwild1@gmail.com>
parents:
12411
diff
changeset
|
61 end); |
18a3a6218100
net.connect: When more targets are immediately available, try them after a delay
Matthew Wild <mwild1@gmail.com>
parents:
12411
diff
changeset
|
62 end |
8531
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
63 end); |
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
64 end |
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
65 |
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
66 function pending_connection_listeners.onconnect(conn) |
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
67 local p = pending_connections_map[conn]; |
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
68 if not p then |
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
69 log("warn", "Successful connection, but unexpected! Closing."); |
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
70 conn:close(); |
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
71 return; |
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
72 end |
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
73 pending_connections_map[conn] = nil; |
12411
e132a4279914
net.connect: Support for multiple pending connection attempts
Matthew Wild <mwild1@gmail.com>
parents:
12205
diff
changeset
|
74 if p.connected then |
e132a4279914
net.connect: Support for multiple pending connection attempts
Matthew Wild <mwild1@gmail.com>
parents:
12205
diff
changeset
|
75 -- We already succeeded in connecting |
e132a4279914
net.connect: Support for multiple pending connection attempts
Matthew Wild <mwild1@gmail.com>
parents:
12205
diff
changeset
|
76 p.conns[conn] = nil; |
e132a4279914
net.connect: Support for multiple pending connection attempts
Matthew Wild <mwild1@gmail.com>
parents:
12205
diff
changeset
|
77 conn:close(); |
e132a4279914
net.connect: Support for multiple pending connection attempts
Matthew Wild <mwild1@gmail.com>
parents:
12205
diff
changeset
|
78 return; |
e132a4279914
net.connect: Support for multiple pending connection attempts
Matthew Wild <mwild1@gmail.com>
parents:
12205
diff
changeset
|
79 end |
e132a4279914
net.connect: Support for multiple pending connection attempts
Matthew Wild <mwild1@gmail.com>
parents:
12205
diff
changeset
|
80 p.connected = true; |
8531
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
81 p:log("debug", "Successfully connected"); |
9387
33e52f727f0f
net.connect: Fix passing request table to new listener
Kim Alvefur <zash@zash.se>
parents:
9386
diff
changeset
|
82 conn:setlistener(p.listeners, p.data); |
8531
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
83 return p.listeners.onconnect(conn); |
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
84 end |
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
85 |
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
86 function pending_connection_listeners.ondisconnect(conn, reason) |
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
87 local p = pending_connections_map[conn]; |
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
88 if not p then |
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
89 log("warn", "Failed connection, but unexpected!"); |
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
90 return; |
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
91 end |
12411
e132a4279914
net.connect: Support for multiple pending connection attempts
Matthew Wild <mwild1@gmail.com>
parents:
12205
diff
changeset
|
92 p.conns[conn] = nil; |
12468
353836684009
net.connect: Fix accumulation of connection attempt references
Kim Alvefur <zash@zash.se>
parents:
12426
diff
changeset
|
93 pending_connections_map[conn] = nil; |
8546
d66916dc318a
net.connect: Track last connection error
Matthew Wild <mwild1@gmail.com>
parents:
8536
diff
changeset
|
94 p.last_error = reason or "unknown reason"; |
d66916dc318a
net.connect: Track last connection error
Matthew Wild <mwild1@gmail.com>
parents:
8536
diff
changeset
|
95 p:log("debug", "Connection attempt failed: %s", p.last_error); |
12426
7a3da1acace1
net.connect: Improve logging on connection attempt failure
Matthew Wild <mwild1@gmail.com>
parents:
12425
diff
changeset
|
96 if p.connected then |
7a3da1acace1
net.connect: Improve logging on connection attempt failure
Matthew Wild <mwild1@gmail.com>
parents:
12425
diff
changeset
|
97 p:log("debug", "Connection already established, ignoring failure"); |
7a3da1acace1
net.connect: Improve logging on connection attempt failure
Matthew Wild <mwild1@gmail.com>
parents:
12425
diff
changeset
|
98 elseif next(p.conns) == nil then |
12425
eabcc3ae22e9
net.connect: Improve handling of failure when attempts are still pending
Matthew Wild <mwild1@gmail.com>
parents:
12412
diff
changeset
|
99 p:log("debug", "No pending connection attempts, and not yet connected"); |
eabcc3ae22e9
net.connect: Improve handling of failure when attempts are still pending
Matthew Wild <mwild1@gmail.com>
parents:
12412
diff
changeset
|
100 attempt_connection(p); |
12426
7a3da1acace1
net.connect: Improve logging on connection attempt failure
Matthew Wild <mwild1@gmail.com>
parents:
12425
diff
changeset
|
101 else |
7a3da1acace1
net.connect: Improve logging on connection attempt failure
Matthew Wild <mwild1@gmail.com>
parents:
12425
diff
changeset
|
102 p:log("debug", "Other attempts are still pending, ignoring failure"); |
12425
eabcc3ae22e9
net.connect: Improve handling of failure when attempts are still pending
Matthew Wild <mwild1@gmail.com>
parents:
12412
diff
changeset
|
103 end |
8531
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
104 end |
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
105 |
10623
f51c88baeb8a
Backed out changeset 44ef46e1a951 (not optimal API)
Matthew Wild <mwild1@gmail.com>
parents:
10612
diff
changeset
|
106 local function connect(target_resolver, listeners, options, data) |
f51c88baeb8a
Backed out changeset 44ef46e1a951 (not optimal API)
Matthew Wild <mwild1@gmail.com>
parents:
10612
diff
changeset
|
107 local p = setmetatable({ |
f51c88baeb8a
Backed out changeset 44ef46e1a951 (not optimal API)
Matthew Wild <mwild1@gmail.com>
parents:
10612
diff
changeset
|
108 id = new_id(); |
f51c88baeb8a
Backed out changeset 44ef46e1a951 (not optimal API)
Matthew Wild <mwild1@gmail.com>
parents:
10612
diff
changeset
|
109 target_resolver = target_resolver; |
f51c88baeb8a
Backed out changeset 44ef46e1a951 (not optimal API)
Matthew Wild <mwild1@gmail.com>
parents:
10612
diff
changeset
|
110 listeners = assert(listeners); |
f51c88baeb8a
Backed out changeset 44ef46e1a951 (not optimal API)
Matthew Wild <mwild1@gmail.com>
parents:
10612
diff
changeset
|
111 options = options or {}; |
f51c88baeb8a
Backed out changeset 44ef46e1a951 (not optimal API)
Matthew Wild <mwild1@gmail.com>
parents:
10612
diff
changeset
|
112 data = data; |
12411
e132a4279914
net.connect: Support for multiple pending connection attempts
Matthew Wild <mwild1@gmail.com>
parents:
12205
diff
changeset
|
113 conns = {}; |
10623
f51c88baeb8a
Backed out changeset 44ef46e1a951 (not optimal API)
Matthew Wild <mwild1@gmail.com>
parents:
10612
diff
changeset
|
114 }, pending_connection_mt); |
8531
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
115 |
10623
f51c88baeb8a
Backed out changeset 44ef46e1a951 (not optimal API)
Matthew Wild <mwild1@gmail.com>
parents:
10612
diff
changeset
|
116 p:log("debug", "Starting connection process"); |
f51c88baeb8a
Backed out changeset 44ef46e1a951 (not optimal API)
Matthew Wild <mwild1@gmail.com>
parents:
10612
diff
changeset
|
117 attempt_connection(p); |
8531
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
118 end |
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
119 |
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
120 return { |
10623
f51c88baeb8a
Backed out changeset 44ef46e1a951 (not optimal API)
Matthew Wild <mwild1@gmail.com>
parents:
10612
diff
changeset
|
121 connect = connect; |
8531
601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
122 }; |