]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/inspircd.cpp
Add a counter for errored files
[user/henk/code/inspircd.git] / src / inspircd.cpp
index 1f46fa875c15c613168ce0b4b96740247dedcaac..87af7b06e8bca45c064c0904ea352b2d0f893f0c 100644 (file)
@@ -70,9 +70,6 @@ const char* ExitCodes[] =
 
 void InspIRCd::Cleanup()
 {
-       std::vector<std::string> mymodnames;
-       int MyModCount = this->Modules->GetCount();
-
        if (Config)
        {
                for (unsigned int i = 0; i < Config->ports.size(); i++)
@@ -97,19 +94,12 @@ void InspIRCd::Cleanup()
         */
        for (int tries = 0; tries < 3; tries++)
        {
-               MyModCount = this->Modules->GetCount();
-               mymodnames.clear();
-
-               if (MyModCount)
+               std::vector<std::string> module_names = Modules->GetAllModuleNames(0);
+               for (std::vector<std::string>::iterator k = module_names.begin(); k != module_names.end(); ++k)
                {
                        /* Unload all modules, so they get a chance to clean up their listeners */
-                       for (int j = 0; j <= MyModCount; j++)
-                               mymodnames.push_back(Config->module_names[j]);
-
-                       for (int k = 0; k <= MyModCount; k++)
-                               this->Modules->Unload(mymodnames[k].c_str());
+                       this->Modules->Unload(k->c_str());
                }
-
        }
 
        /* Close logging */
@@ -436,11 +426,9 @@ InspIRCd::InspIRCd(int argc, char** argv)
        Config->forcedebug = do_debug;
        Config->writelog = !do_nolog;   
        Config->ClearStack();
-       Config->Read(true, NULL);
 
-       // Get XLine to do it's thing.
-       this->XLines->CheckELines();
-       this->XLines->ApplyLines();
+       this->Modes = new ModeParser(this);
+       this->AddServerName(Config->ServerName);
 
        /*
         * Initialise SID/UID.
@@ -499,21 +487,51 @@ InspIRCd::InspIRCd(int argc, char** argv)
 
        SE->RecoverFromFork();
 
-       this->Modes = new ModeParser(this);
-       this->AddServerName(Config->ServerName);
-       CheckDie();
-       int bounditems = BindPorts(true, found_ports, pl);
+       this->Res = new DNS(this);
 
-       for(int t = 0; t < 255; t++)
-               Config->global_implementation[t] = 0;
+       /* Read config, pass 0. At the end if this pass,
+        * the Config->IncludeFiles is populated, we call
+        * Config->StartDownloads to initialize the downlaods of all
+        * these files.
+        */
+        Config->Read(true, NULL, 0);
+       Config->StartDownloads();
+       
+       /* Now the downloads are started, we monitor them for completion.
+        * On completion, we call Read again with pass = 1.
+        * NOTE: We really should add a timeout here
+        */
 
-       memset(&Config->implement_lists,0,sizeof(Config->implement_lists));
+       while (Config->Downloading())
+       {
+               SE->DispatchEvents();
+               this->BufferedSocketCull();
+       }
 
        printf("\n");
 
-       this->Res = new DNS(this);
+       if (Config->FileErrors)
+       {
+               /* One or more file download/access errors, do not
+                * proceed to second pass
+                */
+               Exit(EXIT_STATUS_CONFIG);
+       }
 
-       this->Modules->LoadAll();
+       /* We have all the files we can get, initiate pass 1 */
+       Config->Read(true, NULL, 1);
+
+        // Get XLine to do it's thing.
+        this->XLines->CheckELines();
+        this->XLines->ApplyLines();
+
+
+       CheckDie();
+       int bounditems = BindPorts(true, found_ports, pl);
+
+       printf("\n");
+
+       /*this->Modules->LoadAll();*/
        
        /* Just in case no modules were loaded - fix for bug #101 */
        this->BuildISupport();
@@ -715,18 +733,13 @@ int main(int argc, char ** argv)
  */
 bool InspIRCd::AllModulesReportReady(User* user)
 {
-       if (!Config->global_implementation[I_OnCheckReady])
-               return true;
-
-       for (int i = 0; i <= this->Modules->GetCount(); i++)
+       for (EventHandlerIter i = Modules->EventHandlers[I_OnCheckReady].begin(); i != Modules->EventHandlers[I_OnCheckReady].end(); ++i)
        {
-               if (Config->implement_lists[i][I_OnCheckReady])
-               {
-                       int res = this->Modules->modules[i]->OnCheckReady(user);
-                       if (!res)
-                               return false;
-               }
+               int res = (*i)->OnCheckReady(user);
+               if (!res)
+                       return false;
        }
+
        return true;
 }