aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2008-12-05 19:24:01 +0000
committerMatthew Wild <mwild1@gmail.com>2008-12-05 19:24:01 +0000
commit0d2b952b610069996f733700117a2e62d5b73696 (patch)
tree85b082e3702efeb0e019107679816862619730cd /net
parent32371bbb23449dc86e5d66c54ae862747bc7f398 (diff)
downloadprosody-0d2b952b610069996f733700117a2e62d5b73696.tar.gz
prosody-0d2b952b610069996f733700117a2e62d5b73696.zip
Add TLS socket to readlist before handshake starts, fixes major slow-down on TLS connections
Diffstat (limited to 'net')
-rw-r--r--net/server.lua16
-rw-r--r--net/xmppclient_listener.lua2
2 files changed, 13 insertions, 5 deletions
diff --git a/net/server.lua b/net/server.lua
index 9d178cb2..d840d51b 100644
--- a/net/server.lua
+++ b/net/server.lua
@@ -504,13 +504,24 @@ wraptlsclient = function( listener, socket, ip, serverport, clientport, mode, ss
handler.starttls = function (now)
if not now then out_put("server.lua: we need to do tls, but delaying until later"); handler.need_tls = true; return; end
out_put( "server.lua: attempting to start tls on "..tostring(socket) )
+ local oldsocket = socket;
socket, err = ssl_wrap( socket, sslctx ) -- wrap socket
out_put("sslwrapped socket is "..tostring(socket));
if err then
out_put( "server.lua: ssl error: ", err )
return nil, nil, err -- fatal error
end
- socket:settimeout( 1 )
+ socket:settimeout(0);
+
+ -- Add the new socket to our system
+ socketlist[ socket ] = handler
+ readlen = readlen + 1
+ readlist[ readlen ] = socket
+
+ -- Remove traces of the old socket
+ readlen = removesocket( readlist, oldsocket, readlen )
+ socketlist [ oldsocket ] = nil;
+
send = socket.send
receive = socket.receive
close = socket.close
@@ -536,9 +547,6 @@ wraptlsclient = function( listener, socket, ip, serverport, clientport, mode, ss
handler.receivedata = handler._receivedata -- when handshake is done, replace the handshake function with regular functions
handler.dispatchdata = handler._dispatchdata
handler.need_tls = nil
- socketlist[ client ] = handler
- readlen = readlen + 1
- readlist[ readlen ] = client
return true;
else
out_put( "server.lua: error during ssl handshake: ", err )
diff --git a/net/xmppclient_listener.lua b/net/xmppclient_listener.lua
index 22af2de4..fe6ec57b 100644
--- a/net/xmppclient_listener.lua
+++ b/net/xmppclient_listener.lua
@@ -113,7 +113,7 @@ function xmppclient.listener(conn, data)
if not session then
session = sm_new_session(conn);
sessions[conn] = session;
-
+
-- Logging functions --
local mainlog, log = log;