summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2010-08-29 19:28:04 -0400
committerAdam <Adam@anope.org>2010-08-29 19:28:04 -0400
commitf2769273652f61f1d620c98a94b9c95983ed5647 (patch)
tree6d8c77e680258c095221d4ef98cf04845666d621
parentd70f1a43bc9520b3db22534fee07a047be4fa4d1 (diff)
Redo some of the sighandling code, and made anoperc rehash actually work.
-rw-r--r--data/example.conf8
-rw-r--r--docs/Changes.conf1
-rw-r--r--include/config.h2
-rw-r--r--include/modules.h3
-rw-r--r--modules/socketengines/m_socketengine_epoll.cpp2
-rw-r--r--modules/socketengines/m_socketengine_select.cpp2
-rw-r--r--src/bin/anoperc.in3
-rw-r--r--src/config.cpp1
-rw-r--r--src/main.cpp107
9 files changed, 40 insertions, 89 deletions
diff --git a/data/example.conf b/data/example.conf
index 9f103a971..d7c7c9372 100644
--- a/data/example.conf
+++ b/data/example.conf
@@ -441,14 +441,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)
{
-#ifndef _WIN32
- if (signum == SIGHUP)
+ switch (signum)
{
- Log() << "Received SIGHUP: Saving Databases & Rehash Configuration";
-
- expire_all();
- save_databases();
+#ifndef _WIN32
+ case SIGHUP:
+ Log() << "Received SIGHUP: Saving Databases & Rehash Configuration";
- 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;
+ expire_all();
+ save_databases();
- }
- else
+ 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
- if (signum == SIGTERM)
- {
- signal(SIGTERM, SIG_IGN);
+ case SIGINT:
+ case SIGTERM:
+ signal(signum, SIG_IGN);
#ifndef _WIN32
- signal(SIGHUP, SIG_IGN);
+ signal(SIGHUP, SIG_IGN);
#endif
- Log() << "Received SIGTERM, exiting.";
+ Log() << "Received " << strsignal(signum) << " signal (" << signum << "), 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);
- }
+ quitmsg = "shutting down on sigterm";
+ default:
+ fatal = true;
+ break;
}
}
- /* Should we send the signum here as well? -GD */
- FOREACH_MOD(I_OnSignal, OnSignal(quitmsg));
-
- if (started)
- {
- services_shutdown();
- exit(0);
- }
- else
- {
- if (isatty(2))
- fprintf(stderr, "%s\n", quitmsg.c_str());
- else
- Log() << quitmsg;
+ FOREACH_MOD(I_OnSignal, OnSignal(signum, 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;
}