Software /
code /
prosody
Diff
net/server_select.lua @ 2307:fc7e0962520a
net.server_select: Add a function to just lock a stream for reading
author | Sjoerd Simons <sjoerd.simons@collabora.co.uk> |
---|---|
date | Thu, 03 Dec 2009 16:53:58 +0100 |
parent | 2304:26f59e5e5c03 |
child | 2312:5ddbb9c89ffe |
line wrap: on
line diff
--- a/net/server_select.lua Thu Dec 03 14:15:30 2009 +0000 +++ b/net/server_select.lua Thu Dec 03 16:53:58 2009 +0100 @@ -436,7 +436,25 @@ maxreadlen = readlen or maxreadlen return bufferlen, maxreadlen, maxsendlen end + handler.lock_read = function (self, switch) + if switch == true then + local tmp = _readlistlen + _readlistlen = removesocket( _readlist, socket, _readlistlen ) + _readtimes[ handler ] = nil + if _readlistlen ~= tmp then + noread = true + end + elseif switch == false then + 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 @@ -445,19 +463,8 @@ if _sendlistlen ~= tmp then nosend = true end - 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 if nosend then nosend = false write( "" )