Created
January 19, 2015 19:12
-
-
Save daurnimator/3e8c62cf1e74ded21da2 to your computer and use it in GitHub Desktop.
stdin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# HG changeset patch | |
# User daurnimator <quae@daurnimator.com> | |
# Date 1421694071 18000 | |
# Mon Jan 19 14:01:11 2015 -0500 | |
# Node ID 8921aaedeea7a48630c2396c2c45eeaf6abf8b22 | |
# Parent 31a8b3bfb31d6145c3a8a2b789d2d3f92eed0dc9 | |
net.server_select: Remove do-nothing os_difftime calls | |
diff -r 31a8b3bfb31d -r 8921aaedeea7 net/server_select.lua | |
--- a/net/server_select.lua Thu Jan 15 09:05:08 2015 -0500 | |
+++ b/net/server_select.lua Mon Jan 19 14:01:11 2015 -0500 | |
@@ -38,7 +38,6 @@ | |
--// lua lib methods //-- | |
-local os_difftime = os.difftime | |
local math_min = math.min | |
local math_huge = math.huge | |
local table_concat = table.concat | |
@@ -923,17 +922,16 @@ | |
_currenttime = luasocket_gettime( ) | |
-- Check for socket timeouts | |
- local difftime = os_difftime( _currenttime - _starttime ) | |
- if difftime > _checkinterval then | |
+ if _currenttime - _starttime > _checkinterval then | |
_starttime = _currenttime | |
for handler, timestamp in pairs( _writetimes ) do | |
- if os_difftime( _currenttime - timestamp ) > _sendtimeout then | |
+ if _currenttime - timestamp > _sendtimeout then | |
handler.disconnect( )( handler, "send timeout" ) | |
handler:force_close() -- forced disconnect | |
end | |
end | |
for handler, timestamp in pairs( _readtimes ) do | |
- if os_difftime( _currenttime - timestamp ) > _readtimeout then | |
+ if _currenttime - timestamp > _readtimeout then | |
if not(handler.onreadtimeout) or handler:onreadtimeout() ~= true then | |
handler.disconnect( )( handler, "read timeout" ) | |
handler:close( ) -- forced disconnect? | |
# HG changeset patch | |
# User daurnimator <quae@daurnimator.com> | |
# Date 1421694337 18000 | |
# Mon Jan 19 14:05:37 2015 -0500 | |
# Node ID 1fc8514cf5ac73b7866f4e342724e416762db469 | |
# Parent 8921aaedeea7a48630c2396c2c45eeaf6abf8b22 | |
net.server_select: Remove socket.sleep call from main loop | |
It's been there since the start; but should really not be required. | |
People can remember an issue with FreeBSD that this solved, but this was a hack solution anyway. | |
If that issue rears it's head again, we will solve it properly. | |
diff -r 8921aaedeea7 -r 1fc8514cf5ac net/server_select.lua | |
--- a/net/server_select.lua Mon Jan 19 14:01:11 2015 -0500 | |
+++ b/net/server_select.lua Mon Jan 19 14:05:37 2015 -0500 | |
@@ -57,7 +57,6 @@ | |
local ssl_wrap = ( has_luasec and luasec.wrap ) | |
local socket_bind = luasocket.bind | |
-local socket_sleep = luasocket.sleep | |
local socket_select = luasocket.select | |
--// functions //-- | |
@@ -101,7 +100,6 @@ | |
local _readtraffic | |
local _selecttimeout | |
-local _sleeptime | |
local _tcpbacklog | |
local _starttime | |
@@ -138,7 +136,6 @@ | |
_readtraffic = 0 | |
_selecttimeout = 1 -- timeout of socket.select | |
-_sleeptime = 0 -- time to wait at the end of every loop | |
_tcpbacklog = 128 -- some kind of hint to the OS | |
_maxsendlen = 51000 * 1024 -- max len of send buffer | |
@@ -790,7 +787,6 @@ | |
getsettings = function( ) | |
return { | |
select_timeout = _selecttimeout; | |
- select_sleep_time = _sleeptime; | |
tcp_backlog = _tcpbacklog; | |
max_send_buffer_size = _maxsendlen; | |
max_receive_buffer_size = _maxreadlen; | |
@@ -808,7 +804,6 @@ | |
return nil, "invalid settings table" | |
end | |
_selecttimeout = tonumber( new.select_timeout ) or _selecttimeout | |
- _sleeptime = tonumber( new.select_sleep_time ) or _sleeptime | |
_maxsendlen = tonumber( new.max_send_buffer_size ) or _maxsendlen | |
_maxreadlen = tonumber( new.max_receive_buffer_size ) or _maxreadlen | |
_checkinterval = tonumber( new.select_idle_check_interval ) or _checkinterval | |
@@ -941,9 +936,6 @@ | |
end | |
end | |
end | |
- | |
- -- wait some time (0 by default) | |
- socket_sleep( _sleeptime ) | |
until quitting; | |
if once and quitting == "once" then quitting = nil; return; end | |
return "quitting" | |
# HG changeset patch | |
# User daurnimator <quae@daurnimator.com> | |
# Date 1421694553 18000 | |
# Mon Jan 19 14:09:13 2015 -0500 | |
# Node ID 79914530b3fec2c655e134e2390a09a2de206484 | |
# Parent 1fc8514cf5ac73b7866f4e342724e416762db469 | |
net.server_select: Remove unused code | |
diff -r 1fc8514cf5ac -r 79914530b3fe net/server_select.lua | |
--- a/net/server_select.lua Mon Jan 19 14:05:37 2015 -0500 | |
+++ b/net/server_select.lua Mon Jan 19 14:09:13 2015 -0500 | |
@@ -31,7 +31,6 @@ | |
--// lua libs //-- | |
-local os = use "os" | |
local table = use "table" | |
local string = use "string" | |
local coroutine = use "coroutine" | |
@@ -287,7 +286,6 @@ | |
local bufferqueuelen = 0 -- end of buffer array | |
local toclose | |
- local fatalerror | |
local needtls | |
local bufferlen = 0 | |
@@ -499,7 +497,6 @@ | |
return dispatch( handler, buffer, err ) | |
else -- connections was closed or fatal error | |
out_put( "server.lua: client ", tostring(ip), ":", tostring(clientport), " read error: ", tostring(err) ) | |
- fatalerror = true | |
_ = handler and handler:force_close( err ) | |
return false | |
end | |
@@ -539,7 +536,6 @@ | |
return true | |
else -- connection was closed during sending or fatal error | |
out_put( "server.lua: client ", tostring(ip), ":", tostring(clientport), " write error: ", tostring(err) ) | |
- fatalerror = true | |
_ = handler and handler:force_close( err ) | |
return false | |
end | |
@@ -1011,8 +1007,6 @@ | |
end | |
end | |
---// EXPERIMENTAL //-- | |
- | |
----------------------------------// BEGIN //-- | |
use "setmetatable" ( _socketlist, { __mode = "k" } ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment