Diff

net/server.lua @ 6485:4224abbf0fdd

net/server: Handle lack of util.signal correctly
author daurnimator <quae@daurnimator.com>
date Wed, 22 Oct 2014 16:00:40 -0400
parent 6484:913585bca01f
child 7099:8e64e7b82928
line wrap: on
line diff
--- a/net/server.lua	Wed Oct 22 15:59:51 2014 -0400
+++ b/net/server.lua	Wed Oct 22 16:00:40 2014 -0400
@@ -66,9 +66,9 @@
 end
 
 -- If server.hook_signal exists, replace signal.signal()
-local ok, signal = pcall(require, "util.signal");
-if server.hook_signal then
-	if ok then
+local has_signal, signal = pcall(require, "util.signal");
+if has_signal then
+	if server.hook_signal then
 		function signal.signal(signal_id, handler)
 			if type(signal_id) == "string" then
 				signal_id = signal[signal_id:upper()];
@@ -78,9 +78,15 @@
 			end
 			return server.hook_signal(signal_id, handler);
 		end
+	else
+		server.hook_signal = signal.signal;
 	end
 else
-	server.hook_signal = signal.signal;
+	if not server.hook_signal then
+		server.hook_signal = function()
+			return false, "signal hooking not supported"
+		end
+	end
 end
 
 if prosody then