ports.clear();
/* Close all client sockets, or the new process inherits them */
- std::vector<LocalUser*>::reverse_iterator i = Users->local_users.rbegin();
+ LocalUserList::reverse_iterator i = Users->local_users.rbegin();
while (i != this->Users->local_users.rend())
{
User* u = *i++;
i->second->ResetMaxBans();
}
-/** Because hash_map doesn't free its buckets when we delete items, we occasionally
- * recreate the hash to free them up.
- * We do this by copying the entries from the old hash to a new hash, causing all
- * empty buckets to be weeded out of the hash.
- * Since this is quite expensive, it's not done very often.
- */
-void InspIRCd::RehashUsersAndChans()
-{
- user_hash* old_users = Users->clientlist;
- Users->clientlist = new user_hash;
- for (user_hash::const_iterator n = old_users->begin(); n != old_users->end(); n++)
- Users->clientlist->insert(*n);
- delete old_users;
-
- user_hash* old_uuid = Users->uuidlist;
- Users->uuidlist = new user_hash;
- for (user_hash::const_iterator n = old_uuid->begin(); n != old_uuid->end(); n++)
- Users->uuidlist->insert(*n);
- delete old_uuid;
-
- chan_hash* old_chans = chanlist;
- chanlist = new chan_hash;
- for (chan_hash::const_iterator n = old_chans->begin(); n != old_chans->end(); n++)
- chanlist->insert(*n);
- delete old_chans;
-
- // Reset the already_sent IDs so we don't wrap it around and drop a message
- LocalUser::already_sent_id = 0;
- for (std::vector<LocalUser*>::const_iterator i = Users->local_users.begin(); i != Users->local_users.end(); i++)
- {
- (**i).already_sent = 0;
- (**i).RemoveExpiredInvites();
- }
-}
-
void InspIRCd::SetSignals()
{
#ifndef _WIN32
OperQuit("OperQuit", NULL),
GenRandom(&HandleGenRandom),
IsChannel(&HandleIsChannel),
- IsSID(&HandleIsSID),
Rehash(&HandleRehash),
IsNick(&HandleIsNick),
IsIdent(&HandleIsIdent),
- FloodQuitUser(&HandleFloodQuitUser),
OnCheckExemption(&HandleOnCheckExemption)
{
ServerInstance = this;
this->Modes = 0;
this->Res = 0;
this->ConfigThread = NULL;
+ this->FakeClient = NULL;
UpdateTime();
this->startup_time = TIME.tv_sec;
};
int index;
- while ((c = getopt_long(argc, argv, ":f:", longopts, &index)) != -1)
+ while ((c = getopt_long(argc, argv, ":c:f:", longopts, &index)) != -1)
{
switch (c)
{
this->CheckRoot();
else
{
- std::cout << "* WARNING * WARNING * WARNING * WARNING * WARNING *" << std::endl\r
- << "YOU ARE RUNNING INSPIRCD AS ROOT. THIS IS UNSUPPORTED" << std::endl\r
- << "AND IF YOU ARE HACKED, CRACKED, SPINDLED OR MUTILATED" << std::endl\r
- << "OR ANYTHING ELSE UNEXPECTED HAPPENS TO YOU OR YOUR" << std::endl\r
- << "SERVER, THEN IT IS YOUR OWN FAULT. IF YOU DID NOT MEAN" << std::endl\r
- << "TO START INSPIRCD AS ROOT, HIT CTRL+C NOW AND RESTART" << std::endl\r
- << "THE PROGRAM AS A NORMAL USER. YOU HAVE BEEN WARNED!" << std::endl << std::endl\r
- << "InspIRCd starting in 20 seconds, ctrl+c to abort..." << std::endl;\r
+ std::cout << "* WARNING * WARNING * WARNING * WARNING * WARNING *" << std::endl
+ << "YOU ARE RUNNING INSPIRCD AS ROOT. THIS IS UNSUPPORTED" << std::endl
+ << "AND IF YOU ARE HACKED, CRACKED, SPINDLED OR MUTILATED" << std::endl
+ << "OR ANYTHING ELSE UNEXPECTED HAPPENS TO YOU OR YOUR" << std::endl
+ << "SERVER, THEN IT IS YOUR OWN FAULT. IF YOU DID NOT MEAN" << std::endl
+ << "TO START INSPIRCD AS ROOT, HIT CTRL+C NOW AND RESTART" << std::endl
+ << "THE PROGRAM AS A NORMAL USER. YOU HAVE BEEN WARNED!" << std::endl << std::endl
+ << "InspIRCd starting in 20 seconds, ctrl+c to abort..." << std::endl;
sleep(20);
}
#endif
*/
if ((!do_nofork) && (!do_testsuite) && (!Config->cmdline.forcedebug))
{
- int fd;
+ int fd = open("/dev/null", O_RDWR);
fclose(stdin);
fclose(stderr);
fclose(stdout);
- fd = open("/dev/null", O_RDWR);
- if (dup2(fd, 0) < 0)
+ if (dup2(fd, STDIN_FILENO) < 0)
Logs->Log("STARTUP", DEFAULT, "Failed to dup /dev/null to stdin.");
- if (dup2(fd, 1) < 0)
+ if (dup2(fd, STDOUT_FILENO) < 0)
Logs->Log("STARTUP", DEFAULT, "Failed to dup /dev/null to stdout.");
- if (dup2(fd, 2) < 0)
+ if (dup2(fd, STDERR_FILENO) < 0)
Logs->Log("STARTUP", DEFAULT, "Failed to dup /dev/null to stderr.");
close(fd);
}
*/
if (TIME.tv_sec != OLDTIME)
{
- OLDTIME = TIME.tv_sec;
#ifndef _WIN32
getrusage(RUSAGE_SELF, &ru);
stats->LastSampled = TIME;
SNO->WriteToSnoMask('d', "\002EH?!\002 -- Time is jumping FORWARDS! Clock skipped %lu secs.", (unsigned long)TIME.tv_sec - OLDTIME);
}
+ OLDTIME = TIME.tv_sec;
+
if ((TIME.tv_sec % 3600) == 0)
{
- this->RehashUsersAndChans();
+ Users->GarbageCollect();
FOREACH_MOD(I_OnGarbageCollect, OnGarbageCollect());
}