Changeset

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
parents 3542:2acaf129e1c3
children 3544:f2aca3e0fe3b
files net/server_select.lua
diffstat 1 files changed, 1 insertions(+), 1 deletions(-) [+]
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();