diff options
author | Kim Alvefur <zash@zash.se> | 2018-10-28 16:53:10 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2018-10-28 16:53:10 +0100 |
commit | 9fe357101e6a870bc94ec27577abc022c62bc6da (patch) | |
tree | d3fc5a3be3b54c832ecc62345d7d633f7806fe3c /net/server_select.lua | |
parent | eff5acbce1361ea628ac44fe8cb980ed876c6661 (diff) | |
download | prosody-9fe357101e6a870bc94ec27577abc022c62bc6da.tar.gz prosody-9fe357101e6a870bc94ec27577abc022c62bc6da.zip |
net.server_select: Move code from :lock_read into :pause and :resume
Diffstat (limited to 'net/server_select.lua')
-rw-r--r-- | net/server_select.lua | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/net/server_select.lua b/net/server_select.lua index 1c016633..51a74c94 100644 --- a/net/server_select.lua +++ b/net/server_select.lua @@ -459,26 +459,28 @@ wrapconnection = function( server, listeners, socket, ip, serverport, clientport handler.lock_read = function (self, switch) out_error( "server.lua, lock_read() is deprecated, use pause() and resume()" ) if switch == true then - local tmp = _readlistlen - _readlistlen = removesocket( _readlist, socket, _readlistlen ) - _readtimes[ handler ] = nil - if _readlistlen ~= tmp then - noread = true - end + return self:pause() elseif switch == false then - if noread then - noread = false - _readlistlen = addsocket(_readlist, socket, _readlistlen) - _readtimes[ handler ] = _currenttime - end + return self:resume() end return noread end handler.pause = function (self) - return self:lock_read(true); + local tmp = _readlistlen + _readlistlen = removesocket( _readlist, socket, _readlistlen ) + _readtimes[ handler ] = nil + if _readlistlen ~= tmp then + noread = true + end + return noread; end handler.resume = function (self) - return self:lock_read(false); + if noread then + noread = false + _readlistlen = addsocket(_readlist, socket, _readlistlen) + _readtimes[ handler ] = _currenttime + end + return noread; end handler.lock = function( self, switch ) handler.lock_read (switch) |