Changeset

9576:913a17d6c449

net.server_select: Move code from :lock_read into :pause and :resume
author Kim Alvefur <zash@zash.se>
date Sun, 28 Oct 2018 16:53:10 +0100
parents 9575:1fb3e7c550bf
children 9577:388b93b3eecf
files net/server_select.lua
diffstat 1 files changed, 15 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/net/server_select.lua	Sun Oct 28 16:51:58 2018 +0100
+++ b/net/server_select.lua	Sun Oct 28 16:53:10 2018 +0100
@@ -459,26 +459,28 @@
 	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)