]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules.cpp
Fix ModuleManager error caused by a lack of arguments.
[user/henk/code/inspircd.git] / src / modules.cpp
index ccd78a8f028c63d6790c04fa499a50c5d2ae9696..a7b3364ae1c919ba5b075837ea087ef86e75e630 100644 (file)
@@ -32,7 +32,7 @@
 #include "dns.h"
 #include "exitcodes.h"
 
-#ifndef WIN32
+#ifndef _WIN32
        #include <dirent.h>
 #endif
 
@@ -176,6 +176,7 @@ ModResult   Module::OnNumeric(User*, unsigned int, const std::string&) { return MO
 void           Module::OnHookIO(StreamSocket*, ListenSocket*) { }
 ModResult   Module::OnAcceptConnection(int, ListenSocket*, irc::sockets::sockaddrs*, irc::sockets::sockaddrs*) { return MOD_RES_PASSTHRU; }
 void           Module::OnSendWhoLine(User*, const std::vector<std::string>&, User*, std::string&) { }
+void           Module::OnSetUserIP(LocalUser*) { }
 
 ModuleManager::ModuleManager() : ModCount(0)
 {
@@ -327,7 +328,7 @@ bool ModuleManager::CanUnload(Module* mod)
 {
        std::map<std::string, Module*>::iterator modfind = Modules.find(mod->ModuleSourceFile);
 
-       if (modfind == Modules.end() || modfind->second != mod)
+       if ((modfind == Modules.end()) || (modfind->second != mod) || (mod->dying))
        {
                LastModuleError = "Module " + mod->ModuleSourceFile + " is not loaded, cannot unload it!";
                ServerInstance->Logs->Log("MODULE", DEFAULT, LastModuleError);
@@ -339,6 +340,8 @@ bool ModuleManager::CanUnload(Module* mod)
                ServerInstance->Logs->Log("MODULE", DEFAULT, LastModuleError);
                return false;
        }
+
+       mod->dying = true;
        return true;
 }
 
@@ -447,7 +450,8 @@ void ModuleManager::AddService(ServiceProvider& item)
                                throw ModuleException("Mode "+std::string(item.name)+" already exists.");
                        return;
                case SERVICE_METADATA:
-                       ServerInstance->Extensions.Register(static_cast<ExtensionItem*>(&item));
+                       if (!ServerInstance->Extensions.Register(static_cast<ExtensionItem*>(&item)))
+                               throw ModuleException("Extension " + std::string(item.name) + " already exists.");
                        return;
                case SERVICE_DATA:
                case SERVICE_IOHOOK:
@@ -557,7 +561,7 @@ dynamic_reference_base::operator bool()
                if (i != ServerInstance->Modules->DataProviders.end())
                        value = static_cast<DataProvider*>(i->second);
        }
-       return value;
+       return (value != NULL);
 }
 
 void InspIRCd::SendMode(const std::vector<std::string>& parameters, User *user)