fix: signal handling (#1375)

* fix: signal handling

* fix: flush WorldServer logger before main loop

* fix: consolidate signal code
This commit is contained in:
Daniel Seiler
2024-01-02 04:50:00 +01:00
committed by GitHub
parent 18feea5fed
commit 85672e060a
13 changed files with 92 additions and 45 deletions

View File

@@ -1,5 +1,6 @@
#pragma once
#include <string>
#include <csignal>
#include "RakPeerInterface.h"
#include "ReplicaManager.h"
#include "NetworkIDManager.h"
@@ -15,6 +16,10 @@ enum class ServerType : uint32_t {
World
};
namespace Game {
using signal_t = volatile std::sig_atomic_t;
}
class dServer {
public:
// Default constructor should only used for testing!
@@ -31,7 +36,7 @@ public:
int masterPort,
ServerType serverType,
dConfig* config,
bool* shouldShutdown,
Game::signal_t* shouldShutdown,
unsigned int zoneID = 0);
~dServer();
@@ -81,9 +86,9 @@ private:
NetworkIDManager* mNetIDManager = nullptr;
/**
* Whether or not to shut down the server. Pointer to Game::shouldShutdown.
* Whether or not to shut down the server. Pointer to Game::lastSignal.
*/
bool* mShouldShutdown = nullptr;
Game::signal_t* mShouldShutdown = nullptr;
SocketDescriptor mSocketDescriptor;
std::string mIP;
int mPort;