Some updates
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
//
|
||||
// Created by wolverindev on 01.04.18.
|
||||
//
|
||||
|
||||
#include <log/LogUtils.h>
|
||||
#include <StringVariable.h>
|
||||
#include <ThreadPool/ThreadHelper.h>
|
||||
#include "ShutdownHelper.h"
|
||||
#include "InstanceHandler.h"
|
||||
|
||||
@@ -13,7 +10,6 @@ using namespace ts;
|
||||
using namespace ts::server;
|
||||
|
||||
extern bool mainThreadActive;
|
||||
extern ts::server::InstanceHandler* serverInstance;
|
||||
|
||||
bool shuttingDown = false;
|
||||
void ts::server::shutdownInstance(const std::string& message) {
|
||||
@@ -45,7 +41,9 @@ std::shared_ptr<server::ShutdownData> currentShutdown = nullptr;
|
||||
std::shared_ptr<server::ShutdownData> server::scheduledShutdown() { return currentShutdown; }
|
||||
|
||||
inline void broadcastMessage(const std::string& message) {
|
||||
if(!serverInstance || !serverInstance->getVoiceServerManager());
|
||||
if(!serverInstance || !serverInstance->getVoiceServerManager())
|
||||
return;
|
||||
|
||||
for(const auto &server : serverInstance->getVoiceServerManager()->serverInstances()) {
|
||||
if(server->running()) {
|
||||
server->broadcastMessage(server->getServerRoot(), message);
|
||||
@@ -62,8 +60,10 @@ bool server::scheduleShutdown(const std::chrono::system_clock::time_point& time,
|
||||
data->time_point = time;
|
||||
data->reason = reason;
|
||||
|
||||
data->shutdownThread = new threads::Thread(THREAD_EXECUTE_LATER | THREAD_SAVE_OPERATIONS, [data](){ executeScheduledShutdown(data); });
|
||||
data->shutdownThread->name("Shutdown Executor").execute();
|
||||
data->shutdown_thread = std::thread{[data]{
|
||||
executeScheduledShutdown(data);
|
||||
}};
|
||||
threads::name(data->shutdown_thread, "Shutdown executor");
|
||||
currentShutdown = data;
|
||||
return true;
|
||||
}
|
||||
@@ -77,12 +77,10 @@ void server::cancelShutdown(bool notify) {
|
||||
auto current = server::scheduledShutdown();
|
||||
current->active = false;
|
||||
current->shutdownNotify.notify_all();
|
||||
if(current->shutdownThread->join(seconds(3)) != 0) {
|
||||
if(!threads::save_join(current->shutdown_thread)) {
|
||||
logCritical("Could not terminal shutdown thread!");
|
||||
current->shutdown_thread.detach();
|
||||
}
|
||||
delete current->shutdownThread;
|
||||
current->shutdownThread = nullptr;
|
||||
|
||||
currentShutdown = nullptr;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user