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())

Fri, 22 Oct 2010 06:33:30 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Fri, 22 Oct 2010 06:33:30 +0100
changeset 3543
90b21508ac27
parent 3542
2acaf129e1c3
child 3544
f2aca3e0fe3b

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())

net/server_select.lua file | annotate | diff | comparison | revisions
--- 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();

mercurial