Comparison

net/server_select.lua @ 7323:a1570219b865

net.server_select: Remove do-nothing os_difftime calls [backported from trunk]
author daurnimator <quae@daurnimator.com>
date Mon, 19 Jan 2015 14:01:11 -0500
parent 7098:5286e79c6829
child 7324:7e6409462f79
child 7468:2d38a2519d09
comparison
equal deleted inserted replaced
7322:addf60d25356 7323:a1570219b865
36 local string = use "string" 36 local string = use "string"
37 local coroutine = use "coroutine" 37 local coroutine = use "coroutine"
38 38
39 --// lua lib methods //-- 39 --// lua lib methods //--
40 40
41 local os_difftime = os.difftime
42 local math_min = math.min 41 local math_min = math.min
43 local math_huge = math.huge 42 local math_huge = math.huge
44 local table_concat = table.concat 43 local table_concat = table.concat
45 local string_sub = string.sub 44 local string_sub = string.sub
46 local coroutine_wrap = coroutine.wrap 45 local coroutine_wrap = coroutine.wrap
889 _closelist[ handler ] = nil; 888 _closelist[ handler ] = nil;
890 end 889 end
891 _currenttime = luasocket_gettime( ) 890 _currenttime = luasocket_gettime( )
892 891
893 -- Check for socket timeouts 892 -- Check for socket timeouts
894 local difftime = os_difftime( _currenttime - _starttime ) 893 if _currenttime - _starttime > _checkinterval then
895 if difftime > _checkinterval then
896 _starttime = _currenttime 894 _starttime = _currenttime
897 for handler, timestamp in pairs( _writetimes ) do 895 for handler, timestamp in pairs( _writetimes ) do
898 if os_difftime( _currenttime - timestamp ) > _sendtimeout then 896 if _currenttime - timestamp > _sendtimeout then
899 handler.disconnect( )( handler, "send timeout" ) 897 handler.disconnect( )( handler, "send timeout" )
900 handler:force_close() -- forced disconnect 898 handler:force_close() -- forced disconnect
901 end 899 end
902 end 900 end
903 for handler, timestamp in pairs( _readtimes ) do 901 for handler, timestamp in pairs( _readtimes ) do
904 if os_difftime( _currenttime - timestamp ) > _readtimeout then 902 if _currenttime - timestamp > _readtimeout then
905 if not(handler.onreadtimeout) or handler:onreadtimeout() ~= true then 903 if not(handler.onreadtimeout) or handler:onreadtimeout() ~= true then
906 handler.disconnect( )( handler, "read timeout" ) 904 handler.disconnect( )( handler, "read timeout" )
907 handler:close( ) -- forced disconnect? 905 handler:close( ) -- forced disconnect?
908 else 906 else
909 _readtimes[ handler ] = _currenttime -- reset timer 907 _readtimes[ handler ] = _currenttime -- reset timer