mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-29 05:11:55 +01:00
Replace ACE signal handling with Boost
This commit is contained in:
@@ -26,10 +26,9 @@
|
||||
|
||||
#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>
|
||||
#include <boost/asio/signal_set.hpp>
|
||||
|
||||
#include "Common.h"
|
||||
#include "Database/DatabaseEnv.h"
|
||||
@@ -58,21 +57,20 @@ bool stopEvent = false; // Setting it to tru
|
||||
|
||||
LoginDatabaseWorkerPool LoginDatabase; // Accessor to the authserver database
|
||||
|
||||
/// Handle authserver's termination signals
|
||||
class AuthServerSignalHandler : public Trinity::SignalHandler
|
||||
{
|
||||
public:
|
||||
virtual void HandleSignal(int sigNum)
|
||||
{
|
||||
switch (sigNum)
|
||||
{
|
||||
case SIGINT:
|
||||
case SIGTERM:
|
||||
stopEvent = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
void SignalHandler(const boost::system::error_code& error, int signalNumber)
|
||||
{
|
||||
TC_LOG_ERROR("server.authserver", "SIGNAL HANDLER WORKING");
|
||||
if (!error)
|
||||
{
|
||||
switch (signalNumber)
|
||||
{
|
||||
case SIGINT:
|
||||
case SIGTERM:
|
||||
stopEvent = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Print out the usage string for this program on the console.
|
||||
void usage(const char* prog)
|
||||
@@ -170,13 +168,11 @@ extern int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Initialize the signal handlers
|
||||
AuthServerSignalHandler SignalINT, SignalTERM;
|
||||
boost::asio::io_service io_service;
|
||||
|
||||
// Register authservers's signal handlers
|
||||
ACE_Sig_Handler Handler;
|
||||
Handler.register_handler(SIGINT, &SignalINT);
|
||||
Handler.register_handler(SIGTERM, &SignalTERM);
|
||||
boost::asio::signal_set signals(io_service, SIGINT, SIGTERM);
|
||||
|
||||
signals.async_wait(SignalHandler);
|
||||
|
||||
#if defined(_WIN32) || defined(__linux__)
|
||||
|
||||
@@ -259,6 +255,8 @@ extern int main(int argc, char** argv)
|
||||
if (ACE_Reactor::instance()->run_reactor_event_loop(interval) == -1)
|
||||
break;
|
||||
|
||||
io_service.run();
|
||||
|
||||
if ((++loopCounter) == numLoops)
|
||||
{
|
||||
loopCounter = 0;
|
||||
|
||||
Reference in New Issue
Block a user