aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2018-03-23 14:18:27 +0000
committerMatthew Wild <mwild1@gmail.com>2018-03-23 14:18:27 +0000
commit59e03259d1126b6c0bb3a2c2cdea4f967bb23bd8 (patch)
tree5710c3eba810dec6c6ba98f0bb9d9388fb7993e2
parent8a38579fa00e08ea10ff0eee2e4cdb7cd6bb1a3a (diff)
downloadprosody-59e03259d1126b6c0bb3a2c2cdea4f967bb23bd8.tar.gz
prosody-59e03259d1126b6c0bb3a2c2cdea4f967bb23bd8.zip
prosody, util.startup: Switch from async.once() to long-lived thread, to avoid GC
-rwxr-xr-xprosody9
-rw-r--r--util/startup.lua45
2 files changed, 28 insertions, 26 deletions
diff --git a/prosody b/prosody
index b2e74af7..87207f4b 100755
--- a/prosody
+++ b/prosody
@@ -50,8 +50,13 @@ if #arg > 0 and arg[1] ~= "--config" then
end
local startup = require "util.startup";
+local async = require "util.async";
-startup.prosody();
+-- Note: it's important that this thread is not GC'd, as some C libraries
+-- that are initialized here store a pointer to it ( :/ ).
+local thread = async.runner();
+
+thread:run(startup.prosody);
local function loop()
-- Error handler for errors that make it this far
@@ -88,4 +93,4 @@ cleanup();
prosody.events.fire_event("server-stopped");
log("info", "Shutdown complete");
-os.exit(prosody.shutdown_code)
+os.exit(prosody.shutdown_code);
diff --git a/util/startup.lua b/util/startup.lua
index 40c328d5..5c9e070b 100644
--- a/util/startup.lua
+++ b/util/startup.lua
@@ -5,7 +5,6 @@ local startup = {};
local prosody = { events = require "util.events".new() };
local config = require "core.configmanager";
-local async = require "util.async";
local dependencies = require "util.dependencies";
@@ -501,29 +500,27 @@ function startup.prosodyctl()
end
function startup.prosody()
- async.once(function ()
- -- These actions are in a strict order, as many depend on
- -- previous steps to have already been performed
- startup.read_config();
- startup.sanity_check();
- startup.sandbox_require();
- startup.set_function_metatable();
- startup.check_dependencies();
- startup.load_libraries();
- startup.init_global_state();
- startup.init_logging();
- startup.chdir();
- startup.add_global_prosody_functions();
- startup.read_version();
- startup.log_greeting();
- startup.log_dependency_warnings();
- startup.load_secondary_libraries();
- startup.init_http_client();
- startup.init_data_store();
- startup.init_global_protection();
- startup.prepare_to_start();
- startup.notify_started();
- end);
+ -- These actions are in a strict order, as many depend on
+ -- previous steps to have already been performed
+ startup.read_config();
+ startup.sanity_check();
+ startup.sandbox_require();
+ startup.set_function_metatable();
+ startup.check_dependencies();
+ startup.load_libraries();
+ startup.init_global_state();
+ startup.init_logging();
+ startup.chdir();
+ startup.add_global_prosody_functions();
+ startup.read_version();
+ startup.log_greeting();
+ startup.log_dependency_warnings();
+ startup.load_secondary_libraries();
+ startup.init_http_client();
+ startup.init_data_store();
+ startup.init_global_protection();
+ startup.prepare_to_start();
+ startup.notify_started();
end
return startup;