Comparison

net/server_select.lua @ 9580:5fe91bfb734c

net.server_select: Still allow buffering outgoing data on write-locked connections
author Kim Alvefur <zash@zash.se>
date Sun, 28 Oct 2018 17:11:18 +0100
parent 9579:185eed6cbab0
child 9581:1be99aedb0b3
comparison
equal deleted inserted replaced
9579:185eed6cbab0 9580:5fe91bfb734c
422 local write = function( self, data ) 422 local write = function( self, data )
423 if not handler then return false end 423 if not handler then return false end
424 bufferlen = bufferlen + #data 424 bufferlen = bufferlen + #data
425 if bufferlen > maxsendlen then 425 if bufferlen > maxsendlen then
426 _closelist[ handler ] = "send buffer exceeded" -- cannot close the client at the moment, have to wait to the end of the cycle 426 _closelist[ handler ] = "send buffer exceeded" -- cannot close the client at the moment, have to wait to the end of the cycle
427 handler.write = idfalse -- don't write anymore
428 return false 427 return false
429 elseif socket and not _sendlist[ socket ] then 428 elseif not nosend and socket and not _sendlist[ socket ] then
430 _sendlistlen = addsocket(_sendlist, socket, _sendlistlen) 429 _sendlistlen = addsocket(_sendlist, socket, _sendlistlen)
431 end 430 end
432 bufferqueuelen = bufferqueuelen + 1 431 bufferqueuelen = bufferqueuelen + 1
433 bufferqueue[ bufferqueuelen ] = data 432 bufferqueue[ bufferqueuelen ] = data
434 if handler then 433 if handler then
484 end 483 end
485 handler.lock = function( self, switch ) 484 handler.lock = function( self, switch )
486 out_error( "server.lua, lock() is deprecated" ) 485 out_error( "server.lua, lock() is deprecated" )
487 handler.lock_read (self, switch) 486 handler.lock_read (self, switch)
488 if switch == true then 487 if switch == true then
489 handler.write = idfalse
490 local tmp = _sendlistlen 488 local tmp = _sendlistlen
491 _sendlistlen = removesocket( _sendlist, socket, _sendlistlen ) 489 _sendlistlen = removesocket( _sendlist, socket, _sendlistlen )
492 _writetimes[ handler ] = nil 490 _writetimes[ handler ] = nil
493 if _sendlistlen ~= tmp then 491 if _sendlistlen ~= tmp then
494 nosend = true 492 nosend = true
495 end 493 end
496 elseif switch == false then 494 elseif switch == false then
497 handler.write = write
498 if nosend then 495 if nosend then
499 nosend = false 496 nosend = false
500 write( "" ) 497 write( "" )
501 end 498 end
502 end 499 end