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.
remotes/origin/0.11
Matthew Wild 8 years ago
parent 58f5a8c2f0
commit e263a34414
  1. 38
      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

Loading…
Cancel
Save