# HG changeset patch # User daurnimator # Date 1387408277 18000 # Node ID 07f43c7aa0590e8bdc3dcfcbd2dabc12dd0959ae # Parent 36367fb1ecf91ce3970f075ef8e7968aa273f691 net/server_event: pcall require ssl rather than relying on globals diff -r 36367fb1ecf9 -r 07f43c7aa059 net/server_event.lua --- a/net/server_event.lua Wed Dec 18 17:52:28 2013 -0500 +++ b/net/server_event.lua Wed Dec 18 18:11:17 2013 -0500 @@ -716,25 +716,17 @@ end local addserver = ( function( ) - return function( addr, port, listener, pattern, sslcfg, startssl ) -- TODO: check arguments - --vdebug( "creating new tcp server with following parameters:", addr or "nil", port or "nil", sslcfg or "nil", startssl or "nil") + return function( addr, port, listener, pattern, sslctx, startssl ) -- TODO: check arguments + --vdebug( "creating new tcp server with following parameters:", addr or "nil", port or "nil", sslctx or "nil", startssl or "nil") + if sslctx and not has_luasec then + debug "fatal error: luasec not found" + return nil, "luasec not found" + end local server, err = socket.bind( addr, port, cfg.ACCEPT_QUEUE ) -- create server socket if not server then debug( "creating server socket on "..addr.." port "..port.." failed:", err ) return nil, err end - local sslctx - if sslcfg then - if not has_luasec then - debug "fatal error: luasec not found" - return nil, "luasec not found" - end - sslctx, err = sslcfg - if err then - debug( "error while creating new ssl context for server socket:", err ) - return nil, err - end - end local interface = handleserver( server, addr, port, pattern, listener, sslctx, startssl ) -- new server handler debug( "new server created with id:", tostring(interface)) return interface @@ -751,7 +743,7 @@ end function addclient( addr, serverport, listener, pattern, sslctx ) - if sslctx and not ssl then + if sslctx and not has_luasec then debug "need luasec, but not available" return nil, "luasec not found" end