aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2014-10-21 17:26:48 -0400
committerdaurnimator <quae@daurnimator.com>2014-10-21 17:26:48 -0400
commit8dd15926f8b11511330217d5ddef32a9b75e6bdc (patch)
tree83c78b43c6bad415665d8fd158a7fe724dde9055 /net
parentdcd855afaa62797fc8285ff4a7a8e1a8f6279a1f (diff)
downloadprosody-8dd15926f8b11511330217d5ddef32a9b75e6bdc.tar.gz
prosody-8dd15926f8b11511330217d5ddef32a9b75e6bdc.zip
net/server: If server.hook_signal exists, overwrite signal.signal; else make server.hook_signal == signal.signal
No longer server_event specific server.hook_signal will always exist
Diffstat (limited to 'net')
-rw-r--r--net/server.lua34
1 files changed, 18 insertions, 16 deletions
diff --git a/net/server.lua b/net/server.lua
index 449632ca..5c0d0d24 100644
--- a/net/server.lua
+++ b/net/server.lua
@@ -24,22 +24,6 @@ local set_config;
if server_type == "event" then
server = require "net.server_event";
- -- Overwrite signal.signal() because we need to ask libevent to
- -- handle them instead
- local ok, signal = pcall(require, "util.signal");
- if ok and signal then
- local _signal_signal = signal.signal;
- function signal.signal(signal_id, handler)
- if type(signal_id) == "string" then
- signal_id = signal[signal_id:upper()];
- end
- if type(signal_id) ~= "number" then
- return false, "invalid-signal";
- end
- return server.hook_signal(signal_id, handler);
- end
- end
-
local defaults = {};
for k,v in pairs(server.cfg) do
defaults[k] = v;
@@ -82,6 +66,24 @@ else
error("Unsupported server type")
end
+-- If server.hook_signal exists, replace signal.signal()
+local ok, signal = pcall(require, "util.signal");
+if server.hook_signal then
+ if ok then
+ function signal.signal(signal_id, handler)
+ if type(signal_id) == "string" then
+ signal_id = signal[signal_id:upper()];
+ end
+ if type(signal_id) ~= "number" then
+ return false, "invalid-signal";
+ end
+ return server.hook_signal(signal_id, handler);
+ end
+ end
+else
+ server.hook_signal = signal.signal;
+end
+
if prosody then
local config_get = require "core.configmanager".get;
local function load_config()