feat(Core/SignalHandler): Replace ACE signal handling with std (#4877)

This commit is contained in:
Kargatum
2021-03-24 21:50:56 +07:00
committed by GitHub
parent e0d36be56e
commit c4c06a7734
3 changed files with 60 additions and 66 deletions

View File

@@ -15,7 +15,6 @@
#include <ace/Dev_Poll_Reactor.h>
#include <ace/TP_Reactor.h>
#include <ace/ACE.h>
#include <ace/Sig_Handler.h>
#include <openssl/opensslv.h>
#include <openssl/crypto.h>
@@ -46,22 +45,6 @@ bool stopEvent = false; // Setting it to tru
LoginDatabaseWorkerPool LoginDatabase; // Accessor to the authserver database
/// Handle authserver's termination signals
class AuthServerSignalHandler : public acore::SignalHandler
{
public:
void HandleSignal(int sigNum) override
{
switch (sigNum)
{
case SIGINT:
case SIGTERM:
stopEvent = true;
break;
}
}
};
/// Print out the usage string for this program on the console.
void usage(const char* prog)
{
@@ -180,12 +163,15 @@ extern int main(int argc, char** argv)
sLog->outString("Authserver listening to %s:%d", bind_ip.c_str(), rmport);
// Initialize the signal handlers
AuthServerSignalHandler SignalINT, SignalTERM;
acore::SignalHandler signalHandler;
auto const _handler = [](int) { stopEvent = true; };
// Register authservers's signal handlers
ACE_Sig_Handler Handler;
Handler.register_handler(SIGINT, &SignalINT);
Handler.register_handler(SIGTERM, &SignalTERM);
signalHandler.handle_signal(SIGINT, _handler);
signalHandler.handle_signal(SIGTERM, _handler);
#if AC_PLATFORM == AC_PLATFORM_WINDOWS
signalHandler.handle_signal(SIGBREAK, _handler);
#endif
#if defined(_WIN32) || defined(__linux__)