Diff

net/server_select.lua @ 3543:90b21508ac27

net.server_select: Restore real sendbuffer() before calling onconnect handler, in case onconnect sends data and the socket is still writeable (causing stack overflow into sendbuffer()/onconnect())
author Matthew Wild <mwild1@gmail.com>
date Fri, 22 Oct 2010 06:33:30 +0100
parent 3491:e8c06d20a18b
child 3682:d12141cbbaa0
line wrap: on
line diff
--- a/net/server_select.lua	Fri Oct 22 08:36:54 2010 +0500
+++ b/net/server_select.lua	Fri Oct 22 06:33:30 2010 +0100
@@ -853,8 +853,8 @@
 		-- When socket is writeable, call onconnect
 		local _sendbuffer = handler.sendbuffer;
 		handler.sendbuffer = function ()
+			handler.sendbuffer = _sendbuffer;
 			listeners.onconnect(handler);
-			handler.sendbuffer = _sendbuffer;
 			-- If there was data with the incoming packet, handle it now.
 			if #handler:bufferqueue() > 0 then
 				return _sendbuffer();