diff options
author | Sjoerd Simons <sjoerd.simons@collabora.co.uk> | 2009-12-03 16:53:58 +0100 |
---|---|---|
committer | Sjoerd Simons <sjoerd.simons@collabora.co.uk> | 2009-12-03 16:53:58 +0100 |
commit | 2c89ba5b4beaaea1bd0b4bde1717a73c5a437661 (patch) | |
tree | c99ac519fbb50504577ddfd8f7575973e72c42df | |
parent | 7b01ad22db0a52327df3b00961fbcab9144d66d8 (diff) | |
download | prosody-2c89ba5b4beaaea1bd0b4bde1717a73c5a437661.tar.gz prosody-2c89ba5b4beaaea1bd0b4bde1717a73c5a437661.zip |
net.server_select: Add a function to just lock a stream for reading
-rw-r--r-- | net/server_select.lua | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/net/server_select.lua b/net/server_select.lua index 19a2320b..72a43e9c 100644 --- a/net/server_select.lua +++ b/net/server_select.lua @@ -436,28 +436,35 @@ wrapconnection = function( server, listeners, socket, ip, serverport, clientport maxreadlen = readlen or maxreadlen
return bufferlen, maxreadlen, maxsendlen
end
- handler.lock = function( self, switch )
+ handler.lock_read = function (self, switch)
if switch == true then
- handler.write = idfalse
- local tmp = _sendlistlen
- _sendlistlen = removesocket( _sendlist, socket, _sendlistlen )
- _writetimes[ handler ] = nil
- if _sendlistlen ~= tmp then
- nosend = true
- end
- tmp = _readlistlen
+ local tmp = _readlistlen
_readlistlen = removesocket( _readlist, socket, _readlistlen )
_readtimes[ handler ] = nil
if _readlistlen ~= tmp then
noread = true
end
elseif switch == false then
- handler.write = write
if noread then
noread = false
_readlistlen = addsocket(_readlist, socket, _readlistlen)
_readtimes[ handler ] = _currenttime
end
+ end
+ return noread
+ end
+ handler.lock = function( self, switch )
+ handler.lock_read (switch)
+ if switch == true then
+ handler.write = idfalse
+ local tmp = _sendlistlen
+ _sendlistlen = removesocket( _sendlist, socket, _sendlistlen )
+ _writetimes[ handler ] = nil
+ if _sendlistlen ~= tmp then
+ nosend = true
+ end
+ elseif switch == false then
+ handler.write = write
if nosend then
nosend = false
write( "" )
|