X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Finspircd.cpp;h=656be220f6c60d37469dd88f793a5b00bcc7daa2;hb=2550d001423d25b50c7bfdc89f6efe81dbb64612;hp=a67d24a6dc986a4b89e189b2f6a17d043405da8e;hpb=8d419c3873cd3593baf4cc5f66bbe854a3a4614f;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/inspircd.cpp b/src/inspircd.cpp index a67d24a6d..656be220f 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -63,7 +63,6 @@ #include "testsuite.h" InspIRCd* ServerInstance = NULL; -int* mysig = NULL; /** Seperate from the other casemap tables so that code *can* still exclusively rely on RFC casemapping * if it must. @@ -240,6 +239,12 @@ void InspIRCd::SetSignals() } void InspIRCd::QuickExit(int status) +{ + exit(status); +} + +// Required for returning the proper value of EXIT_SUCCESS for the parent process +static void VoidSignalHandler(int signalreceived) { exit(0); } @@ -250,7 +255,8 @@ bool InspIRCd::DaemonSeed() std::cout << "InspIRCd Process ID: " << con_green << GetCurrentProcessId() << con_reset << std::endl; return true; #else - signal(SIGTERM, InspIRCd::QuickExit); + // Do not use QuickExit here: It will exit with status SIGTERM which would break e.g. daemon scripts + signal(SIGTERM, VoidSignalHandler); int childpid; if ((childpid = fork ()) < 0) @@ -375,8 +381,6 @@ InspIRCd::InspIRCd(int argc, char** argv) : // Create base manager classes early, so nothing breaks this->Users = new UserManager; - this->Users->unregistered_count = 0; - this->Users->clientlist = new user_hash(); this->Users->uuidlist = new user_hash(); this->chanlist = new chan_hash(); @@ -472,7 +476,7 @@ InspIRCd::InspIRCd(int argc, char** argv) : /* Set the finished argument values */ Config->cmdline.nofork = (do_nofork != 0); Config->cmdline.forcedebug = (do_debug != 0); - Config->cmdline.writelog = (!do_nolog != 0); + Config->cmdline.writelog = !do_nolog; Config->cmdline.TestSuite = (do_testsuite != 0); if (do_debug) @@ -511,7 +515,8 @@ InspIRCd::InspIRCd(int argc, char** argv) : std::cout << con_green << "(C) InspIRCd Development Team." << con_reset << std::endl << std::endl; std::cout << "Developers:" << std::endl; std::cout << con_green << "\tBrain, FrostyCoolSlug, w00t, Om, Special, peavey" << std::endl; - std::cout << "\taquanight, psychon, dz, danieldg, jackmcbarn" << con_reset << std::endl << std::endl; + std::cout << "\taquanight, psychon, dz, danieldg, jackmcbarn" << std::endl; + std::cout << "\tAttila" << con_reset << std::endl << std::endl; std::cout << "Others:\t\t\t" << con_green << "See /INFO Output" << con_reset << std::endl; this->Modes = new ModeParser; @@ -688,7 +693,7 @@ InspIRCd::InspIRCd(int argc, char** argv) : if (!g) { - this->Logs->Log("SETGUID", DEFAULT, "getgrnam() failed (bad user?): %s", strerror(errno)); + this->Logs->Log("SETGUID", DEFAULT, "getgrnam(%s) failed (wrong group?): %s", SetGroup.c_str(), strerror(errno)); this->QuickExit(0); } @@ -696,7 +701,7 @@ InspIRCd::InspIRCd(int argc, char** argv) : if (ret == -1) { - this->Logs->Log("SETGUID", DEFAULT, "setgid() failed (bad user?): %s", strerror(errno)); + this->Logs->Log("SETGUID", DEFAULT, "setgid() failed (wrong group?): %s", strerror(errno)); this->QuickExit(0); } } @@ -711,7 +716,7 @@ InspIRCd::InspIRCd(int argc, char** argv) : if (!u) { - this->Logs->Log("SETGUID", DEFAULT, "getpwnam() failed (bad user?): %s", strerror(errno)); + this->Logs->Log("SETGUID", DEFAULT, "getpwnam(%s) failed (wrong user?): %s", SetUser.c_str(), strerror(errno)); this->QuickExit(0); } @@ -719,7 +724,7 @@ InspIRCd::InspIRCd(int argc, char** argv) : if (ret == -1) { - this->Logs->Log("SETGUID", DEFAULT, "setuid() failed (bad user?): %s", strerror(errno)); + this->Logs->Log("SETGUID", DEFAULT, "setuid() failed (wrong user?): %s", strerror(errno)); this->QuickExit(0); } } @@ -789,7 +794,6 @@ int InspIRCd::Run() */ if (TIME.tv_sec != OLDTIME) { - OLDTIME = TIME.tv_sec; #ifndef _WIN32 getrusage(RUSAGE_SELF, &ru); stats->LastSampled = TIME; @@ -810,12 +814,14 @@ int InspIRCd::Run() /* Allow a buffer of two seconds drift on this so that ntpdate etc dont harass admins */ if (TIME.tv_sec < OLDTIME - 2) { - SNO->WriteToSnoMask('d', "\002EH?!\002 -- Time is flowing BACKWARDS in this dimension! Clock drifted backwards %lu secs.", (unsigned long)OLDTIME-TIME.tv_sec); + SNO->WriteToSnoMask('d', "\002EH?!\002 -- Time is flowing BACKWARDS in this dimension! Clock drifted backwards %lu secs.", (unsigned long)(OLDTIME-TIME.tv_sec)); } else if (TIME.tv_sec > OLDTIME + 2) { - SNO->WriteToSnoMask('d', "\002EH?!\002 -- Time is jumping FORWARDS! Clock skipped %lu secs.", (unsigned long)TIME.tv_sec - OLDTIME); + 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) { @@ -847,10 +853,10 @@ int InspIRCd::Run() GlobalCulls.Apply(); AtomicActions.Run(); - if (this->s_signal) + if (s_signal) { this->SignalHandler(s_signal); - this->s_signal = 0; + s_signal = 0; } } @@ -874,9 +880,11 @@ bool InspIRCd::AllModulesReportReady(LocalUser* user) return (res == MOD_RES_PASSTHRU); } +sig_atomic_t InspIRCd::s_signal = 0; + void InspIRCd::SetSignal(int signal) { - *mysig = signal; + s_signal = signal; } /* On posix systems, the flow of the program starts right here, with @@ -888,7 +896,6 @@ void InspIRCd::SetSignal(int signal) ENTRYPOINT { new InspIRCd(argc, argv); - mysig = &ServerInstance->s_signal; ServerInstance->Run(); delete ServerInstance; return 0;