diff options
author | Adam <Adam@anope.org> | 2012-12-13 06:12:56 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2012-12-13 06:12:56 -0500 |
commit | c1077faa281c5635f85b892e605e23bd6c8fcc3b (patch) | |
tree | 213b5f87a19f182e1efd6110f03ff10d5b10ebf6 /src/main.cpp | |
parent | 76ba147c22944b67e8522cd2bb7b6e1bae498ced (diff) |
Optimize much of the database code and serialize code.
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 39 |
1 files changed, 4 insertions, 35 deletions
diff --git a/src/main.cpp b/src/main.cpp index 82cd1af90..c35ee40d9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -14,7 +14,6 @@ #include "timers.h" #include "config.h" #include "bots.h" -#include "signals.h" #include "socketengine.h" #include "uplink.h" @@ -31,6 +30,7 @@ Anope::string Anope::ServicesDir; Anope::string Anope::ServicesBin; int Anope::ReturnValue = 0; +sig_atomic_t Anope::Signal = 0; bool Anope::Quitting = false; bool Anope::Restarting = false; Anope::string Anope::QuitReason; @@ -63,40 +63,6 @@ void Anope::SaveDatabases() Log(LOG_DEBUG) << "Saving databases"; } -std::vector<Signal *> Signal::SignalHandlers; - -void Signal::SignalHandler(int signal) -{ - for (unsigned i = 0, j = SignalHandlers.size(); i < j; ++i) - if (SignalHandlers[i]->signal == signal) - SignalHandlers[i]->Notify(); -} - -Signal::Signal(int s) : Pipe(), signal(s) -{ - memset(&this->old, 0, sizeof(this->old)); - - this->action.sa_flags = 0; - sigemptyset(&this->action.sa_mask); - this->action.sa_handler = SignalHandler; - - if (sigaction(s, &this->action, &this->old) == -1) - throw CoreException("Unable to install signal " + stringify(s) + ": " + Anope::LastError()); - - SignalHandlers.push_back(this); -} - -Signal::~Signal() -{ - std::vector<Signal *>::iterator it = std::find(SignalHandlers.begin(), SignalHandlers.end(), this); - if (it != SignalHandlers.end()) - SignalHandlers.erase(it); - - sigaction(this->signal, &this->old, NULL); -} - -/*************************************************************************/ - /** The following comes from InspIRCd to get the full path of the Anope executable */ static Anope::string GetFullProgDir(const Anope::string &argv0) @@ -196,6 +162,9 @@ int main(int ac, char **av, char **envp) /* Process the socket engine */ SocketEngine::Process(); + + if (Anope::Signal) + Anope::HandleSignal(); } if (Anope::Restarting) |