Mercurial > prosody-hg
comparison 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 |
| parents | 26f59e5e5c03 |
| children | 5ddbb9c89ffe |
comparison
equal
deleted
inserted
replaced
| 2306:21f0d80f244a | 2307:fc7e0962520a |
|---|---|
| 434 handler.bufferlen = function( self, readlen, sendlen ) | 434 handler.bufferlen = function( self, readlen, sendlen ) |
| 435 maxsendlen = sendlen or maxsendlen | 435 maxsendlen = sendlen or maxsendlen |
| 436 maxreadlen = readlen or maxreadlen | 436 maxreadlen = readlen or maxreadlen |
| 437 return bufferlen, maxreadlen, maxsendlen | 437 return bufferlen, maxreadlen, maxsendlen |
| 438 end | 438 end |
| 439 handler.lock_read = function (self, switch) | |
| 440 if switch == true then | |
| 441 local tmp = _readlistlen | |
| 442 _readlistlen = removesocket( _readlist, socket, _readlistlen ) | |
| 443 _readtimes[ handler ] = nil | |
| 444 if _readlistlen ~= tmp then | |
| 445 noread = true | |
| 446 end | |
| 447 elseif switch == false then | |
| 448 if noread then | |
| 449 noread = false | |
| 450 _readlistlen = addsocket(_readlist, socket, _readlistlen) | |
| 451 _readtimes[ handler ] = _currenttime | |
| 452 end | |
| 453 end | |
| 454 return noread | |
| 455 end | |
| 439 handler.lock = function( self, switch ) | 456 handler.lock = function( self, switch ) |
| 457 handler.lock_read (switch) | |
| 440 if switch == true then | 458 if switch == true then |
| 441 handler.write = idfalse | 459 handler.write = idfalse |
| 442 local tmp = _sendlistlen | 460 local tmp = _sendlistlen |
| 443 _sendlistlen = removesocket( _sendlist, socket, _sendlistlen ) | 461 _sendlistlen = removesocket( _sendlist, socket, _sendlistlen ) |
| 444 _writetimes[ handler ] = nil | 462 _writetimes[ handler ] = nil |
| 445 if _sendlistlen ~= tmp then | 463 if _sendlistlen ~= tmp then |
| 446 nosend = true | 464 nosend = true |
| 447 end | 465 end |
| 448 tmp = _readlistlen | |
| 449 _readlistlen = removesocket( _readlist, socket, _readlistlen ) | |
| 450 _readtimes[ handler ] = nil | |
| 451 if _readlistlen ~= tmp then | |
| 452 noread = true | |
| 453 end | |
| 454 elseif switch == false then | 466 elseif switch == false then |
| 455 handler.write = write | 467 handler.write = write |
| 456 if noread then | |
| 457 noread = false | |
| 458 _readlistlen = addsocket(_readlist, socket, _readlistlen) | |
| 459 _readtimes[ handler ] = _currenttime | |
| 460 end | |
| 461 if nosend then | 468 if nosend then |
| 462 nosend = false | 469 nosend = false |
| 463 write( "" ) | 470 write( "" ) |
| 464 end | 471 end |
| 465 end | 472 end |
