Changeset

2478:7be72eca5666

net.server_{select,event}: Fail gracefully if socket doesn't have a setoption method (LuaSec issue I think)
author Matthew Wild <mwild1@gmail.com>
date Thu, 21 Jan 2010 12:56:08 +0000
parents 2477:a08ba94c2a29
children 2479:9c074ba1f662
files net/server_event.lua net/server_select.lua
diffstat 2 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/net/server_event.lua	Thu Jan 21 12:23:13 2010 +0000
+++ b/net/server_event.lua	Thu Jan 21 12:56:08 2010 +0000
@@ -420,7 +420,10 @@
 	end
 	
 	function interface_mt:setoption(option, value)
-		return self.conn:setoption(option, value);
+		if self.conn.setoption then
+			return self.conn:setoption(option, value);
+		end
+		return false, "setoption not implemented";
 	end
 	
 	-- Stub handlers
--- a/net/server_select.lua	Thu Jan 21 12:23:13 2010 +0000
+++ b/net/server_select.lua	Thu Jan 21 12:56:08 2010 +0000
@@ -354,7 +354,10 @@
         return shutdown( socket, pattern )
     end
     handler.setoption = function (self, option, value)
-    	return socket:setoption(option, value);
+        if socket.setoption then
+            return socket:setoption(option, value);
+        end
+        return false, "setoption not implemented";
     end
     handler.close = function( self, forced )
         if not handler then return true; end