]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules.cpp
m_spy no longer implements SPYNAMES, instead it overrides normal NAMES on the event...
[user/henk/code/inspircd.git] / src / modules.cpp
index 5d52ff204c7eb45536c21087cc9ce736960ebf47..8f32e94acc541054fd1b19fb1713c64fcd6daa70 100644 (file)
@@ -109,7 +109,7 @@ std::string Event::GetEventID()
 void           Module::OnUserConnect(User*) { }
 void           Module::OnUserQuit(User*, const std::string&, const std::string&) { }
 void           Module::OnUserDisconnect(User*) { }
-void           Module::OnUserJoin(User*, Channel*, bool&) { }
+void           Module::OnUserJoin(User*, Channel*, bool, bool&) { }
 void           Module::OnPostJoin(User*, Channel*) { }
 void           Module::OnUserPart(User*, Channel*, const std::string&, bool&) { }
 void           Module::OnRehash(User*, const std::string&) { }
@@ -191,8 +191,6 @@ void                Module::OnText(User*, void*, int, const std::string&, char, CUList&) { }
 
 ModuleManager::ModuleManager(InspIRCd* Ins) : ModCount(0), Instance(Ins)
 {
-       for (int n = I_BEGIN; n != I_END; ++n)
-               EventHandlers.push_back(std::vector<Module*>());
 }
 
 ModuleManager::~ModuleManager()
@@ -241,13 +239,6 @@ bool ModuleManager::SetPriority(Module* mod, PriorityState s)
 
 bool ModuleManager::SetPriority(Module* mod, Implementation i, PriorityState s, Module** modules, size_t sz)
 {
-       if (GetModuleName(mod) != "m_spanningtree.so")
-               Instance->Log(DEBUG,"ModuleManager::SetPriority called by %s, priority state %s num_modules=%u", GetModuleName(mod).c_str(), s == PRIO_BEFORE ? "PRIO_BEFORE" : 
-                       s == PRIO_AFTER ? "PRIO_AFTER" :
-                       s == PRIO_LAST ? "PRIO_LAST" :
-                       s == PRIO_FIRST ? "PRIO_FIRST" : "<unknown!>",
-                       sz);
-
        /** To change the priority of a module, we first find its position in the vector,
         * then we find the position of the other modules in the vector that this module
         * wants to be before/after. We pick off either the first or last of these depending
@@ -278,20 +269,6 @@ bool ModuleManager::SetPriority(Module* mod, Implementation i, PriorityState s,
        if (!found)
                return false;
 
-       Instance->Log(DEBUG,"ModuleManager::SetPriority: My position: %u", source);
-
-       /* Debug stuff. We will probably comment this out some time */
-       if (modules)
-       {
-               for (size_t n = 0; n < sz; ++n)
-               {
-                       if (modules[n])
-                               Instance->Log(DEBUG,"    Listed Module: [%08x] %s", modules[n], GetModuleName(modules[n]).c_str());
-                       else
-                               Instance->Log(DEBUG,"    [null module]");
-               }
-       }
-
        switch (s)
        {
                /* Dummy value */
@@ -350,19 +327,7 @@ bool ModuleManager::SetPriority(Module* mod, Implementation i, PriorityState s,
 
        /* Do we need to swap? */
        if (swap && (swap_pos != source))
-       {
                std::swap(EventHandlers[i][swap_pos], EventHandlers[i][source]);
-               Instance->Log(DEBUG,"Swap locations %u and %u", swap_pos, source);
-       }
-       else
-               Instance->Log(DEBUG,"No need to swap");
-
-       /* Debug stuff. We wont need this some day soon (tm) */
-       Instance->Log(DEBUG,"New ordering:");
-       for (size_t x = 0; x != EventHandlers[i].size(); ++x)
-       {
-               Instance->Log(DEBUG,"  [%08x] %s", EventHandlers[i][x], GetModuleName(EventHandlers[i][x]).c_str());
-       }
 
        return true;
 }
@@ -439,13 +404,15 @@ bool ModuleManager::Load(const char* filename)
                newhandle = new ircd_module(Instance, modfile, "init_module");
                newmod = newhandle->CallInit();
 
-               if(newmod)
+               if (newmod)
                {
                        Version v = newmod->GetVersion();
 
                        if (v.API != API_VERSION)
                        {
+                               DetachAll(newmod);
                                delete newmod;
+                               delete newhandle;
                                LastModuleError = "Unable to load " + filename_str + ": Incorrect module API version: " + ConvToStr(v.API) + " (our version: " + ConvToStr(API_VERSION) + ")";
                                Instance->Log(DEFAULT, LastModuleError);
                                return false;
@@ -459,25 +426,42 @@ bool ModuleManager::Load(const char* filename)
                }
                else
                {
+                       delete newhandle;
                        LastModuleError = "Unable to load " + filename_str + ": Probably missing init_module() entrypoint, but dlsym() didn't notice a problem";
                        Instance->Log(DEFAULT, LastModuleError);
                        return false;
                }
        }
+       /** XXX: Is there anything we can do about this mess? -- Brain */
        catch (LoadModuleException& modexcept)
        {
+               DetachAll(newmod);
+               if (newmod)
+                       delete newmod;
+               if (newhandle)
+                       delete newhandle;
                LastModuleError = "Unable to load " + filename_str + ": Error when loading: " + modexcept.GetReason();
                Instance->Log(DEFAULT, LastModuleError);
                return false;
        }
        catch (FindSymbolException& modexcept)
        {
+               DetachAll(newmod);
+               if (newmod)
+                       delete newmod;
+               if (newhandle)
+                       delete newhandle;
                LastModuleError = "Unable to load " + filename_str + ": Error finding symbol: " + modexcept.GetReason();
                Instance->Log(DEFAULT, LastModuleError);
                return false;
        }
        catch (CoreException& modexcept)
        {
+               DetachAll(newmod);
+               if (newmod)
+                       delete newmod;
+               if (newhandle)
+                       delete newhandle;
                LastModuleError = "Unable to load " + filename_str + ": " + modexcept.GetReason();
                Instance->Log(DEFAULT, LastModuleError);
                return false;