summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-08-11 20:41:04 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-08-11 20:41:04 +0000
commit283563287be02e32ef8a4cad526855faf327f24e (patch)
tree452d8d417c3dc40f6b7a12c1992b5ce427fced54 /src
parentf07b96003452b042301529467d3e682f11f48434 (diff)
Fix module prioritization when a module asks to be after spanningtree, which asks to be last
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11502 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/modules.cpp27
1 files changed, 22 insertions, 5 deletions
diff --git a/src/modules.cpp b/src/modules.cpp
index 87e2de705..66134e3bc 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -288,11 +288,16 @@ bool ModuleManager::SetPriority(Module* mod, Implementation i, Priority s, Modul
break;
/* Module wants to be first, sod everything else */
case PRIORITY_FIRST:
- swap_pos = 0;
+ if (prioritizationState != PRIO_STATE_FIRST)
+ swap = false;
+ else
+ swap_pos = 0;
break;
- /* Module is submissive and wants to be last... awww. */
+ /* Module wants to be last. */
case PRIORITY_LAST:
- if (EventHandlers[i].empty())
+ if (prioritizationState != PRIO_STATE_FIRST)
+ swap = false;
+ else if (EventHandlers[i].empty())
swap_pos = 0;
else
swap_pos = EventHandlers[i].size() - 1;
@@ -339,6 +344,9 @@ bool ModuleManager::SetPriority(Module* mod, Implementation i, Priority s, Modul
/* Do we need to swap? */
if (swap && (swap_pos != source))
{
+ // We are going to change positions; we'll need to run again to verify all requirements
+ if (prioritizationState == PRIO_STATE_LAST)
+ prioritizationState = PRIO_STATE_AGAIN;
/* Suggestion from Phoenix, "shuffle" the modules to better retain call order */
int incrmnt = 1;
@@ -492,8 +500,17 @@ bool ModuleManager::Load(const char* filename)
* not just the one thats loading, as the new module could affect the preference
* of others
*/
- for (std::map<std::string, std::pair<ircd_module*, Module*> >::iterator n = Modules.begin(); n != Modules.end(); ++n)
- n->second.second->Prioritize();
+ for(int tries = 0; tries < 20; tries++)
+ {
+ prioritizationState = tries > 0 ? PRIO_STATE_LAST : PRIO_STATE_FIRST;
+ for (std::map<std::string, std::pair<ircd_module*, Module*> >::iterator n = Modules.begin(); n != Modules.end(); ++n)
+ n->second.second->Prioritize();
+
+ if (prioritizationState == PRIO_STATE_LAST)
+ break;
+ if (tries == 19)
+ Instance->Logs->Log("MODULE", DEFAULT, "Hook priority dependency loop detected while loading " + filename_str);
+ }
Instance->BuildISupport();
return true;