From de16238e019223eb1b06eb791ec2abdf29b8700c Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Tue, 12 Nov 2024 17:24:14 +0000 Subject: [PATCH 1/2] Process all socket events before connecting to the uplink. This ensures that the SQL import actually succeeds before we do something that might terminate the process. --- src/init.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/init.cpp b/src/init.cpp index 39d1033c6..e32bafb74 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -556,6 +556,7 @@ void Anope::Init(int ac, char **av) EventReturn MOD_RESULT; FOREACH_RESULT(OnLoadDatabase, MOD_RESULT, ()); static_cast(MOD_RESULT); + SocketEngine::Process(); Log() << "Databases loaded"; FOREACH_MOD(OnPostInit, ()); From 7083c424c25e797a8ffbded27ecb4fc8f93e0dd3 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Tue, 19 Nov 2024 00:18:16 +0000 Subject: [PATCH 2/2] Only process sockets after loading the db when using db_sql{_live}. This avoids slow startups for the 95% of users who are using the db_flatfile database backend. --- modules/database/db_sql.cpp | 8 ++++++++ src/init.cpp | 1 - 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/database/db_sql.cpp b/modules/database/db_sql.cpp index c02edd8aa..1964d136f 100644 --- a/modules/database/db_sql.cpp +++ b/modules/database/db_sql.cpp @@ -159,6 +159,14 @@ class DBSQL : public Module, public Pipe this->import = block->Get("import"); } + void OnPostInit() anope_override + { + // If we are importing from flatfile we need to force a socket engine + // flush to ensure it actually gets written to the database before we + // connect to the uplink. + SocketEngine::Process(); + } + void OnShutdown() anope_override { this->shutting_down = true; diff --git a/src/init.cpp b/src/init.cpp index e32bafb74..39d1033c6 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -556,7 +556,6 @@ void Anope::Init(int ac, char **av) EventReturn MOD_RESULT; FOREACH_RESULT(OnLoadDatabase, MOD_RESULT, ()); static_cast(MOD_RESULT); - SocketEngine::Process(); Log() << "Databases loaded"; FOREACH_MOD(OnPostInit, ());