If a module is loaded after m_spanningtree that it needs, then it will now re-read its configuration file. The code is also now in the right place to pick this up on rehash too not just on load.

git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@10934 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
brain 2009-01-02 23:15:09 +00:00
parent 0aac6a2b2a
commit 7fdb199071
3 changed files with 55 additions and 21 deletions

View File

@ -49,12 +49,12 @@ ModuleSpanningTree::ModuleSpanningTree(InspIRCd* Me)
{
I_OnPreCommand, I_OnGetServerDescription, I_OnUserInvite, I_OnPostLocalTopicChange,
I_OnWallops, I_OnUserNotice, I_OnUserMessage, I_OnBackgroundTimer,
I_OnUserJoin, I_OnChangeLocalUserHost, I_OnChangeName, I_OnUserPart,
I_OnUserJoin, I_OnChangeLocalUserHost, I_OnChangeName, I_OnUserPart, I_OnUnloadModule,
I_OnUserQuit, I_OnUserPostNick, I_OnUserKick, I_OnRemoteKill, I_OnRehash,
I_OnOper, I_OnAddLine, I_OnDelLine, I_ProtoSendMode, I_OnMode,
I_OnOper, I_OnAddLine, I_OnDelLine, I_ProtoSendMode, I_OnMode, I_OnLoadModule,
I_OnStats, I_ProtoSendMetaData, I_OnEvent, I_OnSetAway, I_OnPostCommand
};
ServerInstance->Modules->Attach(eventlist, this, 27);
ServerInstance->Modules->Attach(eventlist, this, 29);
delete ServerInstance->PI;
ServerInstance->PI = new SpanningTreeProtocolInterface(this, Utils, ServerInstance);
@ -714,6 +714,30 @@ void ModuleSpanningTree::OnRehash(User* user, const std::string &parameter)
Utils->ReadConfiguration(true);
}
void ModuleSpanningTree::OnLoadModule(Module* mod, const std::string &name)
{
this->RedoConfig(mod, name);
}
void ModuleSpanningTree::OnUnloadModule(Module* mod, const std::string &name)
{
this->RedoConfig(mod, name);
}
void ModuleSpanningTree::RedoConfig(Module* mod, const std::string &name)
{
/* If m_sha256.so is loaded (we use this for HMAC) or any module implementing a BufferedSocket interface is loaded,
* then we need to re-read our config again taking this into account.
*
* We determine if a module supports BufferedSocket simply by sending it the Request for its BufferedSocket name,
* and if it responds non-NULL, it implements the interface.
*/
if (name == "m_sha256.so" || BufferedSocketNameRequest((Module*)this, mod).Send() != NULL)
{
Utils->ReadConfiguration(true);
}
}
// note: the protocol does not allow direct umode +o except
// via NICK with 8 params. sending OPERTYPE infers +o modechange
// locally.

View File

@ -49,6 +49,8 @@ class ModuleSpanningTree : public Module
CommandRSQuit* command_rsquit;
SpanningTreeUtilities* Utils;
void RedoConfig(Module* mod, const std::string &name);
public:
CacheRefreshTimer *RefreshTimer;
@ -180,6 +182,8 @@ class ModuleSpanningTree : public Module
virtual void ProtoSendMode(void* opaque, TargetTypeFlags target_type, void* target, const std::string &modeline);
virtual void ProtoSendMetaData(void* opaque, TargetTypeFlags target_type, void* target, const std::string &extname, const std::string &extdata);
virtual void OnEvent(Event* event);
virtual void OnLoadModule(Module* mod,const std::string &name);
virtual void OnUnloadModule(Module* mod,const std::string &name);
virtual ~ModuleSpanningTree();
virtual Version GetVersion();
void Prioritize();

View File

@ -155,24 +155,6 @@ SpanningTreeUtilities::SpanningTreeUtilities(InspIRCd* Instance, ModuleSpanningT
this->TreeRoot = new TreeServer(this, ServerInstance, ServerInstance->Config->ServerName, ServerInstance->Config->ServerDesc, ServerInstance->Config->GetSID());
modulelist* ml = ServerInstance->Modules->FindInterface("BufferedSocketHook");
/* Did we find any modules? */
if (ml)
{
/* Yes, enumerate them all to find out the hook name */
for (modulelist::iterator m = ml->begin(); m != ml->end(); m++)
{
/* Make a request to it for its name, its implementing
* BufferedSocketHook so we know its safe to do this
*/
std::string name = BufferedSocketNameRequest((Module*)Creator, *m).Send();
/* Build a map of them */
hooks[name.c_str()] = *m;
hooknames.push_back(name);
}
}
this->ReadConfiguration(true);
}
@ -449,6 +431,30 @@ void SpanningTreeUtilities::RefreshIPCache()
void SpanningTreeUtilities::ReadConfiguration(bool rebind)
{
ConfigReader* Conf = new ConfigReader(ServerInstance);
/* We don't need to worry about these being *unloaded* on the fly, only loaded,
* because we 'use' the interface locking the module in memory.
*/
hooks.clear();
hooknames.clear();
modulelist* ml = ServerInstance->Modules->FindInterface("BufferedSocketHook");
/* Did we find any modules? */
if (ml)
{
/* Yes, enumerate them all to find out the hook name */
for (modulelist::iterator m = ml->begin(); m != ml->end(); m++)
{
/* Make a request to it for its name, its implementing
* BufferedSocketHook so we know its safe to do this
*/
std::string name = BufferedSocketNameRequest((Module*)Creator, *m).Send();
/* Build a map of them */
hooks[name.c_str()] = *m;
hooknames.push_back(name);
}
}
if (rebind)
{
for (unsigned int i = 0; i < Bindings.size(); i++)