Changeset

4468:938d878d8087

net.server_event: Fix :pause() to actually stop reading from the socket, rather than ignoring socket-readable events (!), and :resume() to restart the event listener
author Matthew Wild <mwild1@gmail.com>
date Mon, 16 Jan 2012 04:44:23 +0000
parents 4467:fc8a22936b3c
children 4472:9a4a82629bf3
files net/server_event.lua
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/net/server_event.lua	Fri Jan 13 23:30:32 2012 +0000
+++ b/net/server_event.lua	Mon Jan 16 04:44:23 2012 +0000
@@ -295,7 +295,10 @@
 	end
 
 	function interface_mt:resume()
-		return self:_lock(self.nointerface, false, self.nowriting);
+		self:_lock(self.nointerface, false, self.nowriting);
+		if not self.eventread then
+			self.eventread = addevent( base, self.conn, EV_READ, self.readcallback, cfg.READ_TIMEOUT );  -- register callback
+		end
 	end
 
 	function interface_mt:counter(c)
@@ -642,6 +645,10 @@
 						return -1
 					end
 				end
+				if interface.noreading then
+					interface.eventread = nil;
+					return -1;
+				end
 				return EV_READ, cfg.READ_TIMEOUT
 			end
 		end