]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/inspircd.cpp
kick_channel -> chanrec::KickUser(), server_kick_channel -> chanrec::ServerKickUser()
[user/henk/code/inspircd.git] / src / inspircd.cpp
index f667acf8e7161a1546adbc9f112b64e99d4eece7..27029a6e4b18344e90fd73af88ee1703f05d802e 100644 (file)
@@ -536,12 +536,12 @@ bool InspIRCd::UnloadModule(const char* filename)
                        }
 
                        // found the module
+                       log(DEBUG,"Removing dependent commands...");
+                       Parser->RemoveCommands(filename);
                        log(DEBUG,"Deleting module...");
                        this->EraseModule(j);
                        log(DEBUG,"Erasing module entry...");
                        this->EraseFactory(j);
-                       log(DEBUG,"Removing dependent commands...");
-                       Parser->RemoveCommands(filename);
                        log(DEFAULT,"Module %s unloaded",filename);
                        MODCOUNT--;
                        BuildISupport();
@@ -586,17 +586,17 @@ bool InspIRCd::LoadModule(const char* filename)
                                return false;
                        }
                }
-               ircd_module* a = new ircd_module(modfile);
-               factory[MODCOUNT+1] = a;
-               if (factory[MODCOUNT+1]->LastError())
-               {
-                       log(DEFAULT,"Unable to load %s: %s",modfile,factory[MODCOUNT+1]->LastError());
-                       snprintf(MODERR,MAXBUF,"Loader/Linker error: %s",factory[MODCOUNT+1]->LastError());
-                       return false;
-               }
                try
                {
-                       if (factory[MODCOUNT+1]->factory)
+                       ircd_module* a = new ircd_module(modfile);
+                       factory[MODCOUNT+1] = a;
+                       if (factory[MODCOUNT+1]->LastError())
+                       {
+                               log(DEFAULT,"Unable to load %s: %s",modfile,factory[MODCOUNT+1]->LastError());
+                               snprintf(MODERR,MAXBUF,"Loader/Linker error: %s",factory[MODCOUNT+1]->LastError());
+                               return false;
+                       }
+                       if ((int)factory[MODCOUNT+1]->factory != -1)
                        {
                                Module* m = factory[MODCOUNT+1]->factory->CreateModule(MyServer);
                                modules[MODCOUNT+1] = m;
@@ -616,7 +616,7 @@ bool InspIRCd::LoadModule(const char* filename)
                        else
                        {
                                        log(DEFAULT,"Unable to load %s",modfile);
-                               snprintf(MODERR,MAXBUF,"Factory function failed!");
+                               snprintf(MODERR,MAXBUF,"Factory function failed: Probably missing init_module() entrypoint.");
                                return false;
                        }
                }
@@ -908,7 +908,7 @@ void InspIRCd::DoOneIteration(bool process_module_sockets)
 int InspIRCd::Run()
 {
        /* Until THIS point, ServerInstance == NULL */
-       
+
        this->Res = new DNS();
 
        LoadAllModules(this);
@@ -916,20 +916,34 @@ int InspIRCd::Run()
        /* Just in case no modules were loaded - fix for bug #101 */
        this->BuildISupport();
 
-       printf("\nInspIRCd is now running!\n");
-       
-       if (!Config->nofork)
+       if (!stats->BoundPortCount)
        {
-               fclose(stdout);
-               fclose(stderr);
-               fclose(stdin);
+               printf("\nI couldn't bind any ports! Are you sure you didn't start InspIRCd twice?\n");
+               Exit(ERROR);
        }
 
        /* Add the listening sockets used for client inbound connections
         * to the socket engine
         */
+       log(DEBUG,"%d listeners",stats->BoundPortCount);
        for (unsigned long count = 0; count < stats->BoundPortCount; count++)
-               SE->AddFd(Config->openSockfd[count],true,X_LISTEN);
+       {
+               log(DEBUG,"Add listener: %d",Config->openSockfd[count]);
+               if (!SE->AddFd(Config->openSockfd[count],true,X_LISTEN))
+               {
+                       printf("\nEH? Could not add listener to socketengine. You screwed up, aborting.\n");
+                       Exit(ERROR);
+               }
+       }
+
+       if (!Config->nofork)
+       {
+               fclose(stdout);
+               fclose(stderr);
+               fclose(stdin);
+       }
+
+       printf("\nInspIRCd is now running!\n");
 
        this->WritePID(Config->PID);