summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorattilamolnar <attilamolnar@hush.com>2013-04-21 15:40:19 +0200
committerattilamolnar <attilamolnar@hush.com>2013-04-21 15:40:19 +0200
commit4b8b3eca8cd30fe6c992c86a333b2defa79ba765 (patch)
treec64edc1160350d5d22b7c67a8659c28c3295f2ba /src
parent1250abdc0915975f0a99cdcea1a4f6cb006b0a74 (diff)
m_permchannels Workaround for alphabetical module initialization order
Read database after all modules have been inited Add exception logging Fixes #485 reported by @gholms
Diffstat (limited to 'src')
-rw-r--r--src/modules/m_permchannels.cpp40
1 files changed, 32 insertions, 8 deletions
diff --git a/src/modules/m_permchannels.cpp b/src/modules/m_permchannels.cpp
index b12b9bbeb..a59518b28 100644
--- a/src/modules/m_permchannels.cpp
+++ b/src/modules/m_permchannels.cpp
@@ -172,14 +172,6 @@ public:
ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
OnRehash(NULL);
-
- // Load only when there are no linked servers - we set the TS of the channels we
- // create to the current time, this can lead to desync because spanningtree has
- // no way of knowing what we do
- ProtoServerList serverlist;
- ServerInstance->PI->GetServerList(serverlist);
- if (serverlist.size() < 2)
- LoadDatabase();
}
CullResult cull()
@@ -300,6 +292,38 @@ public:
dirty = false;
}
+ void Prioritize()
+ {
+ // XXX: Load the DB here because the order in which modules are init()ed at boot is
+ // alphabetical, this means we must wait until all modules have done their init()
+ // to be able to set the modes they provide (e.g.: m_stripcolor is inited after us)
+ // Prioritize() is called after all module initialization is complete, consequently
+ // all modes are available now
+
+ static bool loaded = false;
+ if (loaded)
+ return;
+
+ loaded = true;
+
+ // Load only when there are no linked servers - we set the TS of the channels we
+ // create to the current time, this can lead to desync because spanningtree has
+ // no way of knowing what we do
+ ProtoServerList serverlist;
+ ServerInstance->PI->GetServerList(serverlist);
+ if (serverlist.size() < 2)
+ {
+ try
+ {
+ LoadDatabase();
+ }
+ catch (CoreException& e)
+ {
+ ServerInstance->Logs->Log("m_permchannels", DEFAULT, "Error loading permchannels database: " + std::string(e.GetReason()));
+ }
+ }
+ }
+
virtual Version GetVersion()
{
return Version("Provides support for channel mode +P to provide permanent channels",VF_VENDOR);