Comparison

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
comparison
equal deleted inserted replaced
3542:2acaf129e1c3 3543:90b21508ac27
851 _sendlistlen = addsocket(_sendlist, socket, _sendlistlen) 851 _sendlistlen = addsocket(_sendlist, socket, _sendlistlen)
852 if listeners.onconnect then 852 if listeners.onconnect then
853 -- When socket is writeable, call onconnect 853 -- When socket is writeable, call onconnect
854 local _sendbuffer = handler.sendbuffer; 854 local _sendbuffer = handler.sendbuffer;
855 handler.sendbuffer = function () 855 handler.sendbuffer = function ()
856 handler.sendbuffer = _sendbuffer;
856 listeners.onconnect(handler); 857 listeners.onconnect(handler);
857 handler.sendbuffer = _sendbuffer;
858 -- If there was data with the incoming packet, handle it now. 858 -- If there was data with the incoming packet, handle it now.
859 if #handler:bufferqueue() > 0 then 859 if #handler:bufferqueue() > 0 then
860 return _sendbuffer(); 860 return _sendbuffer();
861 end 861 end
862 end 862 end