diff --git a/data/example.conf b/data/example.conf index 9f103a971..d7c7c9372 100644 --- a/data/example.conf +++ b/data/example.conf @@ -440,14 +440,6 @@ options */ #usestrictprivmsg = yes - /* - * If set, Anope will dump core when a segmentation fault occurs. This is - * generally not needed, but if Anope is crashing on your network and you - * want to make a bug report, having a core file will be of great help. - * This directive is optional. - */ - #dumpcore = yes - /* * If set, Services will only show /stats o to IRC Operators. This directive * is optional. diff --git a/docs/Changes.conf b/docs/Changes.conf index e7738c95f..c49953e6d 100644 --- a/docs/Changes.conf +++ b/docs/Changes.conf @@ -23,6 +23,7 @@ operserv:notifications ossgline changed ossnline ** DELETED CONFIGURATION DIRECTIVES ** serverinfo:helpchannel removed because it has been readded in m_helpchan networkinfo:logchannel, logbot, logusers, logmaxusers, logchannel, and options:keeplogs removed because of the log block +dumpcore because it really didn't do anything Anope Version 1.9.2 -------------------- diff --git a/include/config.h b/include/config.h index 5eb998b4a..11969707f 100644 --- a/include/config.h +++ b/include/config.h @@ -538,8 +538,6 @@ class ServerConfig bool UsePrivmsg; /* Services only respond to full PRIVMSG client@services.server.name messages */ bool UseStrictPrivMsg; - /* Dump a core file if we crash */ - bool DumpCore; /* Number of seconds between consecutive uses of the REGISTER command * Not to be confused with NSRegDelay */ unsigned NickRegDelay; diff --git a/include/modules.h b/include/modules.h index ebe56df48..05a0bd1a8 100644 --- a/include/modules.h +++ b/include/modules.h @@ -659,9 +659,10 @@ class CoreExport Module : public virtual Base virtual void OnShutdown() { } /** Called on signal + * @param signum The signum * @param msg The quitmsg */ - virtual void OnSignal(const Anope::string &msg) { } + virtual void OnSignal(int signum, const Anope::string &msg) { } /** Called before a nick expires * @param na The nick diff --git a/modules/socketengines/m_socketengine_epoll.cpp b/modules/socketengines/m_socketengine_epoll.cpp index 4b38fc657..5a2561b25 100644 --- a/modules/socketengines/m_socketengine_epoll.cpp +++ b/modules/socketengines/m_socketengine_epoll.cpp @@ -112,7 +112,7 @@ class SocketEngineEPoll : public SocketEngineBase if (total == -1) { - Log() << "SockEngine::Process(): error " << strerror(errno); + Log() << "SockEngine::Process(): error: " << strerror(errno); return; } diff --git a/modules/socketengines/m_socketengine_select.cpp b/modules/socketengines/m_socketengine_select.cpp index eb5ddab1a..e708693d2 100644 --- a/modules/socketengines/m_socketengine_select.cpp +++ b/modules/socketengines/m_socketengine_select.cpp @@ -65,7 +65,7 @@ class SocketEngineSelect : public SocketEngineBase #ifdef WIN32 errno = WSAGetLastError(); #endif - Log() << "SockEngine::Process(): error" << strerror(errno); + Log() << "SockEngine::Process(): error: " << strerror(errno); } else if (sresult) { diff --git a/src/bin/anoperc.in b/src/bin/anoperc.in index f50174042..94cdd6316 100644 --- a/src/bin/anoperc.in +++ b/src/bin/anoperc.in @@ -93,7 +93,6 @@ elif [ "$1" = "status" ] ; then echo "Anope is not currently running" -## :/ SIGUSR2 is ignored after the first restart so we stop / start Anope for now ## elif [ "$1" = "restart" ] ; then isAnopeRunning echo "Restarting Anope" @@ -105,7 +104,7 @@ elif [ "$1" = "restart" ] ; then elif [ "$1" = "rehash" ] ; then isAnopeRunning echo "Saving Databases and Rehashing Configuration" - kill -12 `cat $ANOPEPID` + kill -1 `cat $ANOPEPID` elif [ "$1" = "version" ] ; then $ANOPROG -version diff --git a/src/config.cpp b/src/config.cpp index 612aecf66..d43f97e6f 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -1009,7 +1009,6 @@ void ServerConfig::Read() {"options", "forceforbidreason", "no", new ValueContainerBool(&this->ForceForbidReason), DT_BOOLEAN, NoValidation}, {"options", "useprivmsg", "no", new ValueContainerBool(&this->UsePrivmsg), DT_BOOLEAN, NoValidation}, {"options", "usestrictprivmsg", "no", new ValueContainerBool(&this->UseStrictPrivMsg), DT_BOOLEAN, NoValidation}, - {"options", "dumpcore", "yes", new ValueContainerBool(&this->DumpCore), DT_BOOLEAN | DT_NORELOAD, NoValidation}, {"options", "hidestatso", "no", new ValueContainerBool(&this->HideStatsO), DT_BOOLEAN, NoValidation}, {"options", "globaloncycle", "no", new ValueContainerBool(&this->GlobalOnCycle), DT_BOOLEAN, NoValidation}, {"options", "globaloncycledown", "", new ValueContainerString(&this->GlobalOnCycleMessage), DT_STRING, ValidateGlobalOnCycle}, diff --git a/src/main.cpp b/src/main.cpp index 64e755b7c..04baf1dd3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -248,81 +248,55 @@ void sighandler(int signum) * QUIT code without having a valid quitmsg. -GD */ if (quitmsg.empty()) - quitmsg = "Services terminating via a signal."; + quitmsg = Anope::string("Services terminating via signal ") + strsignal(signum) + " (" + stringify(signum) + ")"; + bool fatal = false; if (started) { + switch (signum) + { #ifndef _WIN32 - if (signum == SIGHUP) - { - Log() << "Received SIGHUP: Saving Databases & Rehash Configuration"; + case SIGHUP: + Log() << "Received SIGHUP: Saving Databases & Rehash Configuration"; - expire_all(); - save_databases(); - - try - { - ServerConfig *newconfig = new ServerConfig(); - delete Config; - Config = newconfig; - FOREACH_MOD(I_OnReload, OnReload(true)); - } - catch (const ConfigException &ex) - { - Log() << "Error reloading configuration file: " << ex.GetReason(); - } - return; - - } - else -#endif - if (signum == SIGTERM) - { - signal(SIGTERM, SIG_IGN); -#ifndef _WIN32 - signal(SIGHUP, SIG_IGN); -#endif - - Log() << "Received SIGTERM, exiting."; - - expire_all(); - save_databases(); - quitmsg = "Shutting down on SIGTERM"; - services_shutdown(); - exit(0); - } - else if (signum == SIGINT) - { - if (nofork) - { - signal(SIGINT, SIG_IGN); - Log() << "Received SIGINT, exiting."; expire_all(); save_databases(); - quitmsg = "Shutting down on SIGINT"; - services_shutdown(); - exit(0); - } + + try + { + ServerConfig *newconfig = new ServerConfig(); + delete Config; + Config = newconfig; + FOREACH_MOD(I_OnReload, OnReload(true)); + } + catch (const ConfigException &ex) + { + Log() << "Error reloading configuration file: " << ex.GetReason(); + } + break; +#endif + case SIGINT: + case SIGTERM: + signal(signum, SIG_IGN); +#ifndef _WIN32 + signal(SIGHUP, SIG_IGN); +#endif + + Log() << "Received " << strsignal(signum) << " signal (" << signum << "), exiting."; + + expire_all(); + save_databases(); + quitmsg = "shutting down on sigterm"; + default: + fatal = true; + break; } } - /* Should we send the signum here as well? -GD */ - FOREACH_MOD(I_OnSignal, OnSignal(quitmsg)); + FOREACH_MOD(I_OnSignal, OnSignal(signum, quitmsg)); - if (started) - { - services_shutdown(); - exit(0); - } - else - { - if (isatty(2)) - fprintf(stderr, "%s\n", quitmsg.c_str()); - else - Log() << quitmsg; - - exit(1); - } + if (fatal) + throw FatalException(quitmsg); } /*************************************************************************/ @@ -465,21 +439,6 @@ int main(int ac, char **av, char **envp) started = true; -#ifndef _WIN32 - if (Config->DumpCore) - { - rlimit rl; - if (getrlimit(RLIMIT_CORE, &rl) == -1) - Log() << "Failed to getrlimit()!"; - else - { - rl.rlim_cur = rl.rlim_max; - if (setrlimit(RLIMIT_CORE, &rl) == -1) - Log() << "setrlimit() failed, cannot increase coredump size"; - } - } -#endif - /* Set up timers */ time_t last_check = time(NULL); ExpireTimer expireTimer(Config->ExpireTimeout, last_check); @@ -570,6 +529,8 @@ int main(int ac, char **av, char **envp) { if (!ex.GetReason().empty()) Log(LOG_TERMINAL) << ex.GetReason(); + if (started) + services_shutdown(); return -1; }