Comparison

net/server_select.lua @ 3311:88cfe1bba690

net.server_select: Clean up buffer and fire drained callback on successful write before we try and start TLS negotiation (if negotiation fails instantly then we can be left without a handler to use for cleanup) (thanks dersd)
author Matthew Wild <mwild1@gmail.com>
date Fri, 02 Jul 2010 17:24:40 +0100
parent 3310:ddcab5be2a5e
child 3312:12fc7e005e8b
comparison
equal deleted inserted replaced
3310:ddcab5be2a5e 3311:88cfe1bba690
477 end 477 end
478 if succ then -- sending succesful 478 if succ then -- sending succesful
479 bufferqueuelen = 0 479 bufferqueuelen = 0
480 bufferlen = 0 480 bufferlen = 0
481 _sendlistlen = removesocket( _sendlist, socket, _sendlistlen ) -- delete socket from writelist 481 _sendlistlen = removesocket( _sendlist, socket, _sendlistlen ) -- delete socket from writelist
482 _ = needtls and handler:starttls(nil, true)
483 _writetimes[ handler ] = nil 482 _writetimes[ handler ] = nil
484 if drain then 483 if drain then
485 drain(handler) 484 drain(handler)
486 end 485 end
486 _ = needtls and handler:starttls(nil, true)
487 _ = toclose and handler:close( ) 487 _ = toclose and handler:close( )
488 return true 488 return true
489 elseif byte and ( err == "timeout" or err == "wantwrite" ) then -- want write 489 elseif byte and ( err == "timeout" or err == "wantwrite" ) then -- want write
490 buffer = string_sub( buffer, byte + 1, bufferlen ) -- new buffer 490 buffer = string_sub( buffer, byte + 1, bufferlen ) -- new buffer
491 bufferqueue[ 1 ] = buffer -- insert new buffer in queue 491 bufferqueue[ 1 ] = buffer -- insert new buffer in queue