Changeset

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
parents 3310:ddcab5be2a5e
children 3312:12fc7e005e8b 3313:9bcf8d612a52
files net/server_select.lua
diffstat 1 files changed, 1 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/net/server_select.lua	Fri Jul 02 17:23:17 2010 +0100
+++ b/net/server_select.lua	Fri Jul 02 17:24:40 2010 +0100
@@ -479,11 +479,11 @@
 			bufferqueuelen = 0
 			bufferlen = 0
 			_sendlistlen = removesocket( _sendlist, socket, _sendlistlen ) -- delete socket from writelist
-			_ = needtls and handler:starttls(nil, true)
 			_writetimes[ handler ] = nil
 			if drain then
 				drain(handler)
 			end
+			_ = needtls and handler:starttls(nil, true)
 			_ = toclose and handler:close( )
 			return true
 		elseif byte and ( err == "timeout" or err == "wantwrite" ) then -- want write