#include "inspircd_config.h"
#include "inspircd.h"
-#include "inspircd_io.h"
+#include "configreader.h"
#include <unistd.h>
#include <fcntl.h>
#include <sys/errno.h>
#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;
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;
}
catch (ModuleException& modexcept)
{
- log(DEBUG,"Module exception cought: %s",modexcept.GetReason()); \
+ log(DEBUG,"Module exception caught: %s",modexcept.GetReason());
}
if (MOD_RESULT < 0)
/*
* 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++)
* {
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;
}
*/
void DoBackgroundUserStuff(time_t TIME)
{
- CullList* GlobalGoners = new CullList();
+ CullList GlobalGoners;
for (std::vector<userrec*>::iterator count2 = local_users.begin(); count2 != local_users.end(); count2++)
{
if (((unsigned)TIME > (unsigned)curr->timeout) && (curr->registered != 7))
{
log(DEBUG,"InspIRCd: registration timeout: %s",curr->nick);
- GlobalGoners->AddItem(curr,"Registration timeout");
+ GlobalGoners.AddItem(curr,"Registration timeout");
continue;
}
{
curr->dns_done = true;
ServerInstance->stats->statsDnsBad++;
- FullConnectUser(curr,GlobalGoners);
+ FullConnectUser(curr,&GlobalGoners);
continue;
}
if ((curr->dns_done) && (curr->registered == 3) && (AllModulesReportReady(curr)))
{
log(DEBUG,"dns done, registered=3, and modules ready, OK");
- FullConnectUser(curr,GlobalGoners);
+ FullConnectUser(curr,&GlobalGoners);
continue;
}
// This user didn't answer the last ping, remove them
if (!curr->lastping)
{
- GlobalGoners->AddItem(curr,"Ping timeout");
+ GlobalGoners.AddItem(curr,"Ping timeout");
continue;
}
*/
curr->FlushWriteBuf();
- if (curr->GetWriteError() != "")
+ if (*curr->GetWriteError())
{
- GlobalGoners->AddItem(curr,curr->GetWriteError());
+ GlobalGoners.AddItem(curr,curr->GetWriteError());
continue;
}
}
}
/* Remove all the queued users who are due to be quit, free memory used. */
- GlobalGoners->Apply();
- delete GlobalGoners;
- return;
-}
-
-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);
- }
+ GlobalGoners.Apply();
}
-
-/* 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);
-}
-
-