]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/userprocess.cpp
Remove an extern, partly because it's unused, partly because it then gets shadowed...
[user/henk/code/inspircd.git] / src / userprocess.cpp
index 30f7d49f8f98a31d89a75bb26b644cc448cc0223..2adccc36e5f419d1e1515f1f8b8b3aa08314c76c 100644 (file)
@@ -20,7 +20,7 @@ using namespace std;
 
 #include "inspircd_config.h"
 #include "inspircd.h"
-#include "inspircd_io.h"
+#include "configreader.h"
 #include <unistd.h>
 #include <fcntl.h>
 #include <sys/errno.h>
@@ -61,7 +61,6 @@ using namespace std;
 #include "command_parse.h"
 #include "cull_list.h"
 
-extern int MODCOUNT;
 extern struct sockaddr_in client,server;
 extern socklen_t length;
 extern std::vector<Module*> modules;
@@ -70,7 +69,7 @@ extern std::vector<InspSocket*> module_sockets;
 extern time_t TIME;
 extern time_t OLDTIME;
 extern std::vector<userrec*> local_users;
-char LOG_FILE[MAXBUF];
+extern InspSocket* socket_ref[MAX_DESCRIPTORS];
 
 extern InspIRCd* ServerInstance;
 extern ServerConfig *Config;
@@ -101,7 +100,7 @@ void ProcessUser(userrec* cu)
                }
                catch (ModuleException& modexcept)
                {
-                       log(DEBUG,"Module exception cought: %s",modexcept.GetReason()); \
+                       log(DEBUG,"Module exception caught: %s",modexcept.GetReason());
                }
 
                if (MOD_RESULT < 0)
@@ -135,6 +134,8 @@ void ProcessUser(userrec* cu)
 
                /*
                 * XXX - potential replacement for the below using my beloved pointers. --w00t
+                * XXX - no garauntee there's not \0's in the middle of the data,
+                *       and no reason for it to be terminated either. -- Om
                 *
                 * for (char *c = data; data && *data; data++)
                 * {
@@ -316,12 +317,13 @@ void DoSocketTimeouts(time_t TIME)
        for (std::vector<InspSocket*>::iterator a = module_sockets.begin(); a < module_sockets.end(); a++)
        {
                InspSocket* s = (InspSocket*)*a;
-               if (s->Timeout(TIME))
+               if ((s) && (s->GetFd() >= 0) && (s->GetFd() < MAX_DESCRIPTORS) && (socket_ref[s->GetFd()] != NULL) && (s->Timeout(TIME)))
                {
-                       log(DEBUG,"Socket poll returned false, close and bail");
+                       log(DEBUG,"userprocess.cpp: Socket poll returned false, close and bail");
+                       socket_ref[s->GetFd()] = NULL;
                        SE->DelFd(s->GetFd());
-                       s->Close();
                        module_sockets.erase(a);
+                       s->Close();
                        delete s;
                        break;
                }
@@ -404,7 +406,7 @@ void DoBackgroundUserStuff(time_t TIME)
                         */
                        curr->FlushWriteBuf();
 
-                       if (curr->GetWriteError() != "")
+                       if (*curr->GetWriteError())
                        {
                                GlobalGoners.AddItem(curr,curr->GetWriteError());
                                continue;
@@ -415,81 +417,3 @@ void DoBackgroundUserStuff(time_t TIME)
        /* Remove all the queued users who are due to be quit, free memory used. */
        GlobalGoners.Apply();
 }
-
-void OpenLog(char** argv, int argc)
-{
-       if (!*LOG_FILE)
-       {
-               if (Config->logpath == "")
-               {
-                       Config->logpath = GetFullProgDir(argv,argc) + "/ircd.log";
-               }
-       }
-       else
-       {
-               Config->log_file = fopen(LOG_FILE,"a+");
-
-               if (!Config->log_file)
-               {
-                       printf("ERROR: Could not write to logfile %s, bailing!\n\n",Config->logpath.c_str());
-                       Exit(ERROR);
-               }
-
-               return;
-       }
-
-       Config->log_file = fopen(Config->logpath.c_str(),"a+");
-
-       if (!Config->log_file)
-       {
-               printf("ERROR: Could not write to logfile %s, bailing!\n\n",Config->logpath.c_str());
-               Exit(ERROR);
-       }
-}
-
-
-void CheckRoot()
-{
-       if (geteuid() == 0)
-       {
-               printf("WARNING!!! You are running an irc server as ROOT!!! DO NOT DO THIS!!!\n\n");
-               log(DEFAULT,"InspIRCd: startup: not starting with UID 0!");
-               Exit(ERROR);
-       }
-}
-
-
-void CheckDie()
-{
-       if (*Config->DieValue)
-       {
-               printf("WARNING: %s\n\n",Config->DieValue);
-               log(DEFAULT,"Uh-Oh, somebody didn't read their config file: '%s'",Config->DieValue);
-               Exit(ERROR);
-       }
-}
-
-/* We must load the modules AFTER initializing the socket engine, now */
-void LoadAllModules(InspIRCd* ServerInstance)
-{
-       char configToken[MAXBUF];
-
-       MODCOUNT = -1;
-
-       for (int count = 0; count < Config->ConfValueEnum("module",&Config->config_f); count++)
-       {
-               Config->ConfValue("module","name",count,configToken,&Config->config_f);
-               printf("[\033[1;32m*\033[0m] Loading module:\t\033[1;32m%s\033[0m\n",configToken);
-
-               if (!ServerInstance->LoadModule(configToken))
-               {
-                       log(DEFAULT,"Exiting due to a module loader error.");
-                       printf("\nThere was an error loading a module: %s\n\n",ServerInstance->ModuleError());
-                       Exit(0);
-               }
-       }
-
-       log(DEFAULT,"Total loaded modules: %lu",(unsigned long)MODCOUNT+1);
-}
-
-