]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/inspircd.cpp
Trivial: 401 numeric for m_remove when nick or channel cannot be found
[user/henk/code/inspircd.git] / src / inspircd.cpp
index 1df6ee2932f58274fa6fd0f6e80cca08c725a889..9ffc14cf78a91a4770ae3d7c21b7c00c7fa8cb0f 100644 (file)
@@ -26,6 +26,9 @@ using namespace std;
 #include <sys/ioctl.h>
 #include <time.h>
 #include <string>
+#include <exception>
+#include <stdexcept>
+#include <new>
 #ifdef GCC3
 #include <ext/hash_map>
 #else
@@ -193,15 +196,15 @@ InspIRCd::InspIRCd(int argc, char** argv)
        this->MakeLowerMap();
 
         OpenLog(argv, argc);
+       this->stats = new serverstats();
         Config->ClearStack();
         Config->Read(true,NULL);
         CheckRoot();
        this->ModeGrok = new ModeParser();
        this->Parser = new CommandParser();
-       this->stats = new serverstats();
         AddServerName(Config->ServerName);
         CheckDie();
-        stats->BoundPortCount = BindPorts();
+        stats->BoundPortCount = BindPorts(true);
 
        for(int t = 0; t < 255; t++)
                Config->global_implementation[t] = 0;
@@ -212,7 +215,7 @@ InspIRCd::InspIRCd(int argc, char** argv)
        SetSignals();
         if (!Config->nofork)
         {
-                if (DaemonSeed() == ERROR)
+               if (!DaemonSeed())
                 {
                         printf("ERROR: could not go into daemon mode. Shutting down.\n");
                         Exit(ERROR);
@@ -829,9 +832,18 @@ int InspIRCd::Run()
 
 int main(int argc, char** argv)
 {
-        ServerInstance = new InspIRCd(argc, argv);
-        ServerInstance->Run();
-        delete ServerInstance;
-        return 0;
+       try
+       {
+               ServerInstance = new InspIRCd(argc, argv);
+               ServerInstance->Run();
+               delete ServerInstance;
+       }
+       catch (std::bad_alloc)
+       {
+               log(DEFAULT,"You are out of memory! (got exception std::bad_alloc!)");
+               send_error("**** OUT OF MEMORY **** We're gonna need a bigger boat!");
+               printf("Out of memory! (got exception std::bad_alloc!");
+       }
+       return 0;
 }