Changeset

12297:249eb306f668

mod_posix: Run signal handlers in the startup thread
author Kim Alvefur <zash@zash.se>
date Wed, 06 Oct 2021 14:50:47 +0200
parents 12296:49ebac8a5260
children 12298:cb459f8fa740
files plugins/mod_posix.lua
diffstat 1 files changed, 13 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_posix.lua	Wed Oct 06 14:49:26 2021 +0200
+++ b/plugins/mod_posix.lua	Wed Oct 06 14:50:47 2021 +0200
@@ -130,22 +130,28 @@
 	module:add_timer(0, function ()
 		signal.signal("SIGTERM", function ()
 			module:log("warn", "Received SIGTERM");
-			prosody.unlock_globals();
-			prosody.shutdown("Received SIGTERM");
-			prosody.lock_globals();
+			prosody.main_thread:run(function ()
+				prosody.unlock_globals();
+				prosody.shutdown("Received SIGTERM");
+				prosody.lock_globals();
+			end);
 		end);
 
 		signal.signal("SIGHUP", function ()
 			module:log("info", "Received SIGHUP");
-			prosody.reload_config();
+			prosody.main_thread:run(function ()
+				prosody.reload_config();
+			end);
 			-- this also reloads logging
 		end);
 
 		signal.signal("SIGINT", function ()
 			module:log("info", "Received SIGINT");
-			prosody.unlock_globals();
-			prosody.shutdown("Received SIGINT");
-			prosody.lock_globals();
+			prosody.main_thread:run(function ()
+				prosody.unlock_globals();
+				prosody.shutdown("Received SIGINT");
+				prosody.lock_globals();
+			end);
 		end);
 
 		signal.signal("SIGUSR1", function ()