Software /
code /
prosody
Changeset
8663:a7a9d9511dc1
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.
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 22 Mar 2018 21:18:58 +0000 |
parents | 8662:a4e63b037a2a |
children | 8664:d49acc9a8da2 |
files | plugins/mod_posix.lua |
diffstat | 1 files changed, 18 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_posix.lua Thu Mar 15 06:19:57 2018 +0100 +++ b/plugins/mod_posix.lua Thu Mar 22 21:18:58 2018 +0000 @@ -161,23 +161,25 @@ -- 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); + 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("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(); + signal.signal("SIGINT", function () + module:log("info", "Received SIGINT"); + prosody.unlock_globals(); + prosody.shutdown("Received SIGINT"); + prosody.lock_globals(); + end); end); end