Changeset

4429:8e02ba75ef06

net.server_select: Autostart SSL negotiation as the last part of socket setup to avoid a traceback (#262) (thanks Maranda)
author Matthew Wild <mwild1@gmail.com>
date Mon, 28 Nov 2011 03:04:50 +0000
parents 4428:0317b01b6bcd
children 4430:607de4c95129
files net/server_select.lua
diffstat 1 files changed, 10 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/net/server_select.lua	Sat Nov 26 03:50:51 2011 +0000
+++ b/net/server_select.lua	Mon Nov 28 03:04:50 2011 +0000
@@ -596,25 +596,23 @@
 			handler.sendbuffer = handshake
 			handshake( socket ) -- do handshake
 		end
-		handler.readbuffer = _readbuffer
-		handler.sendbuffer = _sendbuffer
-		
-		if sslctx then
-			out_put "server.lua: auto-starting ssl negotiation..."
-			handler.autostart_ssl = true;
-			handler:starttls(sslctx);
-		end
+	end
 
-	else
-		handler.readbuffer = _readbuffer
-		handler.sendbuffer = _sendbuffer
-	end
+	handler.readbuffer = _readbuffer
+	handler.sendbuffer = _sendbuffer
 	send = socket.send
 	receive = socket.receive
 	shutdown = ( ssl and id ) or socket.shutdown
 
 	_socketlist[ socket ] = handler
 	_readlistlen = addsocket(_readlist, socket, _readlistlen)
+
+	if sslctx and luasec then
+		out_put "server.lua: auto-starting ssl negotiation..."
+		handler.autostart_ssl = true;
+		handler:starttls(sslctx);
+	end
+
 	return handler, socket
 end