Diff

net/server_select.lua @ 6382:57d23c26039b

Merge 0.9->0.10
author Kim Alvefur <zash@zash.se>
date Tue, 02 Sep 2014 22:33:11 +0200
parent 6315:7a3e2f2d43fc
parent 6381:9ffd582c65d8
child 6383:ec8878113907
child 6433:b93402cec1c4
line wrap: on
line diff
--- a/net/server_select.lua	Tue Sep 02 17:58:12 2014 +0100
+++ b/net/server_select.lua	Tue Sep 02 22:33:11 2014 +0200
@@ -285,6 +285,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
@@ -316,11 +317,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