Comparison

net/server_event.lua @ 2726:1b9179e04233

net.server_event: Improve and fix potential traceback in logging of new incoming connections
author Matthew Wild <mwild1@gmail.com>
date Mon, 01 Mar 2010 16:45:13 +0000
parent 2708:d9c4ade80ae9
child 2731:373a7c960409
comparison
equal deleted inserted replaced
2724:3fcf1048a896 2726:1b9179e04233
669 if interface._connections >= cfg.MAX_CONNECTIONS then 669 if interface._connections >= cfg.MAX_CONNECTIONS then
670 client:close( ) -- refuse connection 670 client:close( ) -- refuse connection
671 debug( "maximal connections reached, refuse client connection; accept delay:", delay ) 671 debug( "maximal connections reached, refuse client connection; accept delay:", delay )
672 return EV_TIMEOUT, delay -- delay for next accept attemp 672 return EV_TIMEOUT, delay -- delay for next accept attemp
673 end 673 end
674 local ip, port = client:getpeername( ) 674 local client_ip, client_port = client:getpeername( )
675 interface._connections = interface._connections + 1 -- increase connection count 675 interface._connections = interface._connections + 1 -- increase connection count
676 local clientinterface = handleclient( client, ip, port, interface, pattern, listener, nil, sslctx ) 676 local clientinterface = handleclient( client, client_ip, client_port, interface, pattern, listener, nil, sslctx )
677 --vdebug( "client id:", clientinterface, "startssl:", startssl ) 677 --vdebug( "client id:", clientinterface, "startssl:", startssl )
678 if ssl and sslctx then 678 if ssl and sslctx then
679 clientinterface:starttls(sslctx) 679 clientinterface:starttls(sslctx)
680 else 680 else
681 clientinterface:_start_session( clientinterface.onconnect ) 681 clientinterface:_start_session( clientinterface.onconnect )
682 end 682 end
683 debug( "accepted incoming client connection from:", ip, port ) 683 debug( "accepted incoming client connection from:", client_ip or "<unknown IP>", client_port or "<unknown port>", "to", port or "<unknown port>");
684 684
685 client, err = server:accept() -- try to accept again 685 client, err = server:accept() -- try to accept again
686 end 686 end
687 return EV_READ 687 return EV_READ
688 end 688 end