aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2022-06-14 16:28:49 +0200
committerKim Alvefur <zash@zash.se>2022-06-14 16:28:49 +0200
commitd5e749bc8a1a6b003ba858310145745dcad5ec9c (patch)
tree886a16182bf8a44291d345fd52766e4eddc1907d
parentmod_smacks: Fix #1761 by setting a flag earlier (diff)
downloadprosody-d5e749bc8a1a6b003ba858310145745dcad5ec9c.tar.xz
prosody-d5e749bc8a1a6b003ba858310145745dcad5ec9c.zip
util.startup: Fix async waiting for last shutdown steps
Observed problem: When shutting down prosody would immediately exit after waiting for s2s connections to close, skipping the last cleanup events and reporting the exit reason and code. This happens because prosody.main_thread is in a waiting state and queuing startup.shutdown is dispatched trough the main loop via nexttick, but since the main loop was no longer running at that point it proceeded to the end of the prosody script and exited there.
-rwxr-xr-xprosody2
-rw-r--r--util/startup.lua6
2 files changed, 6 insertions, 2 deletions
diff --git a/prosody b/prosody
index 914396c20..ac623ceff 100755
--- a/prosody
+++ b/prosody
@@ -82,4 +82,4 @@ end
loop();
-thread:run(startup.shutdown);
+startup.exit();
diff --git a/util/startup.lua b/util/startup.lua
index ab8b61dad..e2e7db09b 100644
--- a/util/startup.lua
+++ b/util/startup.lua
@@ -353,7 +353,7 @@ function startup.add_global_prosody_functions()
reason = reason;
code = code;
});
- server.setquitting(true);
+ prosody.main_thread:run(startup.shutdown);
end
end
@@ -644,6 +644,10 @@ function startup.shutdown()
prosody.log("debug", "Shutdown reason was: %s", prosody.shutdown_reason or "not specified");
prosody.log("debug", "Exiting with status code: %d", prosody.shutdown_code or 0);
+ server.setquitting(true);
+end
+
+function startup.exit()
os.exit(prosody.shutdown_code);
end