mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-04 09:44:10 +00:00
fix: signal handling (#1375)
* fix: signal handling * fix: flush WorldServer logger before main loop * fix: consolidate signal code
This commit is contained in:
@@ -5,6 +5,7 @@ set(DCOMMON_SOURCES
|
||||
"dConfig.cpp"
|
||||
"Diagnostics.cpp"
|
||||
"Logger.cpp"
|
||||
"Game.cpp"
|
||||
"GeneralUtils.cpp"
|
||||
"LDFFormat.cpp"
|
||||
"MD5.cpp"
|
||||
|
7
dCommon/Game.cpp
Normal file
7
dCommon/Game.cpp
Normal file
@@ -0,0 +1,7 @@
|
||||
#include "Game.h"
|
||||
|
||||
namespace Game {
|
||||
void OnSignal(int signal) {
|
||||
lastSignal = signal;
|
||||
}
|
||||
}
|
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <random>
|
||||
#include <csignal>
|
||||
|
||||
class dServer;
|
||||
class Logger;
|
||||
@@ -16,6 +17,7 @@ class dZoneManager;
|
||||
class PlayerContainer;
|
||||
|
||||
namespace Game {
|
||||
using signal_t = volatile std::sig_atomic_t;
|
||||
extern Logger* logger;
|
||||
extern dServer* server;
|
||||
extern InstanceManager* im;
|
||||
@@ -25,9 +27,14 @@ namespace Game {
|
||||
extern RakPeerInterface* chatServer;
|
||||
extern AssetManager* assetManager;
|
||||
extern SystemAddress chatSysAddr;
|
||||
extern bool shouldShutdown;
|
||||
extern signal_t lastSignal;
|
||||
extern EntityManager* entityManager;
|
||||
extern dZoneManager* zoneManager;
|
||||
extern PlayerContainer playerContainer;
|
||||
extern std::string projectVersion;
|
||||
|
||||
inline bool ShouldShutdown() {
|
||||
return lastSignal != 0;
|
||||
}
|
||||
void OnSignal(int signal);
|
||||
}
|
||||
|
@@ -6,6 +6,8 @@
|
||||
#include <stdarg.h>
|
||||
|
||||
Writer::~Writer() {
|
||||
// Flush before we close
|
||||
Flush();
|
||||
// Dont try to close stdcout...
|
||||
if (!m_Outfile || m_IsConsoleWriter) return;
|
||||
|
||||
|
Reference in New Issue
Block a user