Comparison

net/server_select.lua @ 3398:abc4a52aef02

net.server_select: Remove 'now' parameter from starttls(), and base it on whether the sendbuffer is empty instead
author Matthew Wild <mwild1@gmail.com>
date Thu, 22 Jul 2010 13:19:37 +0100
parent 3382:fea0f8e19e4c
child 3458:9c3ae41e696c
comparison
equal deleted inserted replaced
3397:f376f0bd1d1f 3398:abc4a52aef02
481 _sendlistlen = removesocket( _sendlist, socket, _sendlistlen ) -- delete socket from writelist 481 _sendlistlen = removesocket( _sendlist, socket, _sendlistlen ) -- delete socket from writelist
482 _writetimes[ handler ] = nil 482 _writetimes[ handler ] = nil
483 if drain then 483 if drain then
484 drain(handler) 484 drain(handler)
485 end 485 end
486 _ = needtls and handler:starttls(nil, true) 486 _ = needtls and handler:starttls(nil)
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
562 if not socket then 562 if not socket then
563 return nil, nil, "ssl handshake failed"; 563 return nil, nil, "ssl handshake failed";
564 end 564 end
565 else 565 else
566 local sslctx; 566 local sslctx;
567 handler.starttls = function( self, _sslctx, now ) 567 handler.starttls = function( self, _sslctx)
568 if _sslctx then 568 if _sslctx then
569 sslctx = _sslctx; 569 sslctx = _sslctx;
570 handler:set_sslctx(sslctx); 570 handler:set_sslctx(sslctx);
571 end 571 end
572 if not now then 572 if bufferqueuelen > 0 then
573 out_put "server.lua: we need to do tls, but delaying until later" 573 out_put "server.lua: we need to do tls, but delaying until send buffer empty"
574 needtls = true 574 needtls = true
575 return 575 return
576 end 576 end
577 out_put( "server.lua: attempting to start tls on " .. tostring( socket ) ) 577 out_put( "server.lua: attempting to start tls on " .. tostring( socket ) )
578 local oldsocket, err = socket 578 local oldsocket, err = socket