# HG changeset patch # User daurnimator # Date 1413926808 14400 # Node ID 410067cdeb2f7484f3c6901dbd5e353975a67203 # Parent dbc72cd1332eec95d4aceb9a4b75bd50f7603cf8 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 diff -r dbc72cd1332e -r 410067cdeb2f net/server.lua --- a/net/server.lua Mon Oct 20 16:13:24 2014 -0400 +++ b/net/server.lua Tue Oct 21 17:26:48 2014 -0400 @@ -24,22 +24,6 @@ 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 @@ 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()