Diff

net/server_select.lua @ 6383:ec8878113907

Merge 0.10->trunk
author Kim Alvefur <zash@zash.se>
date Tue, 02 Sep 2014 22:34:32 +0200
parent 6316:e144a1b67c30
parent 6382:57d23c26039b
child 6442:0f4025abbe8f
line wrap: on
line diff
--- a/net/server_select.lua	Sun Aug 31 20:33:47 2014 +0200
+++ b/net/server_select.lua	Tue Sep 02 22:34:32 2014 +0200
@@ -286,6 +286,7 @@
 	local disconnect = listeners.ondisconnect
 	local drain = listeners.ondrain
 	local onreadtimeout = listeners.onreadtimeout;
+	local detach = listeners.ondetach
 
 	local bufferqueue = { } -- buffer array
 	local bufferqueuelen = 0	-- end of buffer array
@@ -317,11 +318,15 @@
 	handler.onreadtimeout = onreadtimeout;
 
 	handler.setlistener = function( self, listeners )
+		if detach then
+			detach(self) -- Notify listener that it is no longer responsible for this connection
+		end
 		dispatch = listeners.onincoming
 		disconnect = listeners.ondisconnect
 		status = listeners.onstatus
 		drain = listeners.ondrain
 		handler.onreadtimeout = listeners.onreadtimeout
+		detach = listeners.ondetach
 	end
 	handler.getstats = function( )
 		return readtraffic, sendtraffic