diff options
author | Matthew Wild <mwild1@gmail.com> | 2010-01-10 15:26:36 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2010-01-10 15:26:36 +0000 |
commit | 5b19c141d9572f9dfa4cd955aa981e10a69b5ff5 (patch) | |
tree | f06bc040288bc5222da6682a5848b1c46540df11 /net/server.lua | |
parent | 20a9ef356173364f87cef69d4ee285172e7b1b9c (diff) | |
download | prosody-5b19c141d9572f9dfa4cd955aa981e10a69b5ff5.tar.gz prosody-5b19c141d9572f9dfa4cd955aa981e10a69b5ff5.zip |
net.server: When libevent backend is in use, override signal.signal to use server.hook_signal
Diffstat (limited to 'net/server.lua')
-rw-r--r-- | net/server.lua | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/net/server.lua b/net/server.lua index f77b216d..0102cee6 100644 --- a/net/server.lua +++ b/net/server.lua @@ -23,6 +23,23 @@ if use_luaevent then function server.addtimer(f) return add_task(1, function (...) f(...); return 1; end); end + + -- 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 + --_signal_signal(signal_id, handler); + return server.hook_signal(signal_id, handler); + end + end else server = require "net.server_select"; package.loaded["net.server"] = server; |