Diff

net/server_event.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 6481:dbc72cd1332e
line wrap: on
line diff
--- a/net/server_event.lua	Sun Aug 31 20:33:47 2014 +0200
+++ b/net/server_event.lua	Tue Sep 02 22:34:32 2014 +0200
@@ -439,9 +439,11 @@
 	end
 
 	function interface_mt:setlistener(listener)
-		self.onconnect, self.ondisconnect, self.onincoming, self.ontimeout, self.onreadtimeout, self.onstatus
-			= listener.onconnect, listener.ondisconnect, listener.onincoming,
-			  listener.ontimeout, listener.onreadtimeout, listener.onstatus;
+		self:ondetach(); -- Notify listener that it is no longer responsible for this connection
+		self.onconnect, self.ondisconnect, self.onincoming, self.ontimeout,
+		self.onreadtimeout, self.onstatus, self.ondetach
+			= listener.onconnect, listener.ondisconnect, listener.onincoming, listener.ontimeout,
+			  listener.onreadtimeout, listener.onstatus, listener.ondetach;
 	end
 
 	-- Stub handlers
@@ -461,6 +463,8 @@
 	end
 	function interface_mt:ondrain()
 	end
+	function interface_mt:ondetach()
+	end
 	function interface_mt:onstatus()
 	end
 end
@@ -488,6 +492,7 @@
 			ontimeout = listener.ontimeout; -- called when fatal socket timeout occurs
 			onreadtimeout = listener.onreadtimeout; -- called when socket inactivity timeout occurs
 			ondrain = listener.ondrain; -- called when writebuffer is empty
+			ondetach = listener.ondetach; -- called when disassociating this listener from this connection
 			onstatus = listener.onstatus; -- called for status changes (e.g. of SSL/TLS)
 			eventread = false, eventwrite = false, eventclose = false,
 			eventhandshake = false, eventstarthandshake = false;  -- event handler