diff options
author | Matthew Wild <mwild1@gmail.com> | 2018-03-22 21:18:58 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2018-03-22 21:18:58 +0000 |
commit | 3422903267b7cbee65ea8ed32df515ff528b32e8 (patch) | |
tree | 55bb91bb529edef529ba730a0d32154de1f3687c | |
parent | 9589a0588ebc9da60dff749ab245f4e6484d6036 (diff) | |
download | prosody-3422903267b7cbee65ea8ed32df515ff528b32e8.tar.gz prosody-3422903267b7cbee65ea8ed32df515ff528b32e8.zip |
mod_posix: Delay setting signal handlers until in the main thread
Signal handlers work by setting a debug hook. Hooks are per-thread, so we need this to be called in the main thread. However module loading is not in the main thread anymore.
-rw-r--r-- | plugins/mod_posix.lua | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/plugins/mod_posix.lua b/plugins/mod_posix.lua index 9b7d59f5..825d3be0 100644 --- a/plugins/mod_posix.lua +++ b/plugins/mod_posix.lua @@ -161,23 +161,25 @@ module:hook("server-stopped", remove_pidfile); -- Set signal handlers if have_signal then - signal.signal("SIGTERM", function () - module:log("warn", "Received SIGTERM"); - prosody.unlock_globals(); - prosody.shutdown("Received SIGTERM"); - prosody.lock_globals(); - end); - - signal.signal("SIGHUP", function () - module:log("info", "Received SIGHUP"); - prosody.reload_config(); - prosody.reopen_logfiles(); - end); - - signal.signal("SIGINT", function () - module:log("info", "Received SIGINT"); - prosody.unlock_globals(); - prosody.shutdown("Received SIGINT"); - prosody.lock_globals(); + module:add_timer(0, function () + signal.signal("SIGTERM", function () + module:log("warn", "Received SIGTERM"); + prosody.unlock_globals(); + prosody.shutdown("Received SIGTERM"); + prosody.lock_globals(); + end); + + signal.signal("SIGHUP", function () + module:log("info", "Received SIGHUP"); + prosody.reload_config(); + prosody.reopen_logfiles(); + end); + + signal.signal("SIGINT", function () + module:log("info", "Received SIGINT"); + prosody.unlock_globals(); + prosody.shutdown("Received SIGINT"); + prosody.lock_globals(); + end); end); end |