]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/inspircd.cpp
Added helperfuncs.h
[user/henk/code/inspircd.git] / src / inspircd.cpp
index 631d4920cbe30ae00dfdaccdb7cbe6caa87daa32..66f15e8729a446af94c14e19f0b366b43f29198c 100644 (file)
@@ -70,9 +70,6 @@
 
 InspIRCd* ServerInstance;
 
-int WHOWAS_STALE = 48; // default WHOWAS Entries last 2 days before they go 'stale'
-int WHOWAS_MAX = 100;  // default 100 people maximum in the WHOWAS list
-
 extern ModuleList modules;
 extern FactoryList factory;
 
@@ -81,12 +78,9 @@ std::vector<userrec*> local_users;
 
 extern int MODCOUNT;
 extern char LOG_FILE[MAXBUF];
-int openSockfd[MAX_DESCRIPTORS];
-int yield_depth;
 int iterations = 0;
 
 insp_sockaddr client, server;
-
 socklen_t length;
 
 extern InspSocket* socket_ref[MAX_DESCRIPTORS];
@@ -141,11 +135,11 @@ void Exit(int status)
        exit (status);
 }
 
-void Start()
+void InspIRCd::Start()
 {
        printf("\033[1;32mInspire Internet Relay Chat Server, compiled %s at %s\n",__DATE__,__TIME__);
        printf("(C) ChatSpike Development team.\033[0m\n\n");
-       printf("Developers:\t\t\033[1;32mBrain, FrostyCoolSlug, w00t, Om\033[0m\n");
+       printf("Developers:\t\t\033[1;32mBrain, FrostyCoolSlug, w00t, Om, Special\033[0m\n");
        printf("Others:\t\t\t\033[1;32mSee /INFO Output\033[0m\n");
        printf("Name concept:\t\t\033[1;32mLord_Zathras\033[0m\n\n");
 }
@@ -167,7 +161,7 @@ void Rehash(int status)
        FOREACH_MOD(I_OnRehash,OnRehash(""));
 }
 
-void SetSignals()
+void InspIRCd::SetSignals()
 {
        signal (SIGALRM, SIG_IGN);
        signal (SIGHUP, Rehash);
@@ -176,7 +170,7 @@ void SetSignals()
        signal (SIGSEGV, Error);
 }
 
-bool DaemonSeed()
+bool InspIRCd::DaemonSeed()
 {
        int childpid;
        if ((childpid = fork ()) < 0)
@@ -207,7 +201,7 @@ bool DaemonSeed()
        return true;
 }
 
-void WritePID(const std::string &filename)
+void InspIRCd::WritePID(const std::string &filename)
 {
        std::ofstream outfile(filename.c_str());
        if (outfile.is_open())
@@ -244,8 +238,9 @@ void InspIRCd::MakeLowerMap()
 
 InspIRCd::InspIRCd(int argc, char** argv)
 {
-       Start();
+       this->Start();
        module_sockets.clear();
+       init_dns();
        this->startup_time = time(NULL);
        srand(time(NULL));
        log(DEBUG,"*** InspIRCd starting up!");
@@ -317,10 +312,10 @@ InspIRCd::InspIRCd(int argc, char** argv)
        memset(&Config->implement_lists,0,sizeof(Config->implement_lists));
 
        printf("\n");
-       SetSignals();
+       this->SetSignals();
        if (!Config->nofork)
        {
-               if (!DaemonSeed())
+               if (!this->DaemonSeed())
                {
                        printf("ERROR: could not go into daemon mode. Shutting down.\n");
                        Exit(ERROR);
@@ -361,7 +356,7 @@ char* InspIRCd::ModuleError()
        return MODERR;
 }
 
-void InspIRCd::erase_factory(int j)
+void InspIRCd::EraseFactory(int j)
 {
        int v = 0;
        for (std::vector<ircd_module*>::iterator t = factory.begin(); t != factory.end(); t++)
@@ -376,7 +371,7 @@ void InspIRCd::erase_factory(int j)
        }
 }
 
-void InspIRCd::erase_module(int j)
+void InspIRCd::EraseModule(int j)
 {
        int v1 = 0;
        for (std::vector<Module*>::iterator m = modules.begin(); m!= modules.end(); m++)
@@ -537,9 +532,9 @@ bool InspIRCd::UnloadModule(const char* filename)
 
                        // found the module
                        log(DEBUG,"Deleting module...");
-                       erase_module(j);
+                       this->EraseModule(j);
                        log(DEBUG,"Erasing module entry...");
-                       erase_factory(j);
+                       this->EraseFactory(j);
                        log(DEBUG,"Removing dependent commands...");
                        Parser->RemoveCommands(filename);
                        log(DEFAULT,"Module %s unloaded",filename);
@@ -694,11 +689,6 @@ void InspIRCd::DoOneIteration(bool process_module_sockets)
        insp_sockaddr sock_us;     // our port number
        socklen_t uslen;         // length of our port number
 
-       if (yield_depth > 100)
-               return;
-
-       yield_depth++;
-
        /* time() seems to be a pretty expensive syscall, so avoid calling it too much.
         * Once per loop iteration is pleanty.
         */
@@ -731,7 +721,6 @@ void InspIRCd::DoOneIteration(bool process_module_sockets)
                }
                TickMissedTimers(TIME);
                expire_run = true;
-               yield_depth--;
                return;
        }   
        else if ((TIME % 5) == 1)
@@ -772,10 +761,7 @@ void InspIRCd::DoOneIteration(bool process_module_sockets)
         * servers... so its nice and easy, just one call.
         */
        if (!(numberactive = SE->Wait(activefds)))
-       {
-               yield_depth--;
                return;
-       }
 
        /**
         * Now process each of the fd's. For users, we have a fast
@@ -851,6 +837,15 @@ void InspIRCd::DoOneIteration(bool process_module_sockets)
 #endif
                        break;
 
+                       case X_ESTAB_CLASSDNS:
+                               /* Handles instances of the Resolver class,
+                                * a simple class extended by modules for
+                                * nonblocking resolving of addresses.
+                                */
+
+                               dns_deal_with_classes(activefds[activefd]);
+                       break;
+
                        case X_LISTEN:
 
                                log(DEBUG,"Type: X_LISTEN_MODULE: fd=%d",activefds[activefd]);
@@ -873,7 +868,7 @@ void InspIRCd::DoOneIteration(bool process_module_sockets)
                                        {
                                                try
                                                {
-                                                       Config->GetIOHook(in_port)->OnRawSocketAccept(incomingSockfd, (char*)inet_ntoa(client.sin_addr), in_port);
+                                                       Config->GetIOHook(in_port)->OnRawSocketAccept(incomingSockfd, inet_ntoa(client.sin_addr), in_port);
                                                }
                                                catch (ModuleException& modexcept)
                                                {
@@ -904,7 +899,6 @@ void InspIRCd::DoOneIteration(bool process_module_sockets)
                        break;
                }
        }
-       yield_depth--;
 }
 
 int InspIRCd::Run()
@@ -929,13 +923,12 @@ int InspIRCd::Run()
         * to the socket engine
         */
        for (int count = 0; count < stats->BoundPortCount; count++)
-               SE->AddFd(openSockfd[count],true,X_LISTEN);
+               SE->AddFd(Config->openSockfd[count],true,X_LISTEN);
 
-       WritePID(Config->PID);
+       this->WritePID(Config->PID);
 
        /* main loop, this never returns */
        expire_run = false;
-       yield_depth = 0;
        iterations = 0;
 
        while (true)