X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fmodules.cpp;h=a7b3364ae1c919ba5b075837ea087ef86e75e630;hb=ac8a394a5c01d8cecd6d1fd364173825ecb452ae;hp=ccd78a8f028c63d6790c04fa499a50c5d2ae9696;hpb=74ee9af96639323d852a8b15be72ee9974e0a826;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules.cpp b/src/modules.cpp index ccd78a8f0..a7b3364ae 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -32,7 +32,7 @@ #include "dns.h" #include "exitcodes.h" -#ifndef WIN32 +#ifndef _WIN32 #include #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&, User*, std::string&) { } +void Module::OnSetUserIP(LocalUser*) { } ModuleManager::ModuleManager() : ModCount(0) { @@ -327,7 +328,7 @@ bool ModuleManager::CanUnload(Module* mod) { std::map::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(&item)); + if (!ServerInstance->Extensions.Register(static_cast(&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(i->second); } - return value; + return (value != NULL); } void InspIRCd::SendMode(const std::vector& parameters, User *user)