Changeset

3138:d6151c9a6f7e

net.multiplex_listener: Test to make sure listener.onconnect isn't nil.
author Waqas Hussain <waqas20@gmail.com>
date Wed, 02 Jun 2010 17:25:01 +0500
parents 3137:463d51ee9a2b
children 3139:7b4f180d7c6f
files net/multiplex_listener.lua
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/net/multiplex_listener.lua	Wed Jun 02 17:06:23 2010 +0500
+++ b/net/multiplex_listener.lua	Wed Jun 02 17:25:01 2010 +0500
@@ -19,6 +19,8 @@
 	if buf:match("^[a-zA-Z]") then
 		local listener = httpserver_listener;
 		conn:setlistener(listener);
+		local onconnect = listener.onconnect;
+		if onconnect then onconnect(conn) end
 		listener.onincoming(conn, buf);
 	elseif buf:match(">") then
 		local listener;
@@ -31,7 +33,8 @@
 			listener = xmppclient_listener;
 		end
 		conn:setlistener(listener);
-		listener.onconnect(conn);
+		local onconnect = listener.onconnect;
+		if onconnect then onconnect(conn) end
 		listener.onincoming(conn, buf);
 	elseif #buf > 1024 then
 		conn:close();