# HG changeset patch
# User Matthew Wild <mwild1@gmail.com>
# Date 1366242085 -3600
# Node ID 307c4b1259b3e1e90a1de3fe87b76783cd397c54
# Parent  421c7830eccc2137c77b8e5d510443007081d924# Parent  5d0cc5de5c51c0d77e6c5e8863fef11b84c6df5e
Merge 0.9->trunk

diff -r 421c7830eccc -r 307c4b1259b3 net/server_select.lua
--- a/net/server_select.lua	Thu Apr 18 00:10:52 2013 +0100
+++ b/net/server_select.lua	Thu Apr 18 00:41:25 2013 +0100
@@ -243,7 +243,7 @@
 			end
 			connections = connections + 1
 			out_put( "server.lua: accepted new client connection from ", tostring(ip), ":", tostring(clientport), " to ", tostring(serverport))
-			if dispatch then
+			if dispatch and not sslctx then -- SSL connections will notify onconnect when handshake completes
 				return dispatch( handler );
 			end
 			return;
@@ -551,6 +551,9 @@
 						handler.readbuffer = _readbuffer	-- when handshake is done, replace the handshake function with regular functions
 						handler.sendbuffer = _sendbuffer
 						_ = status and status( handler, "ssl-handshake-complete" )
+						if self.autostart_ssl and listeners.onconnect then
+							listeners.onconnect(self);
+						end
 						_readlistlen = addsocket(_readlist, client, _readlistlen)
 						return true
 					else