Skip to content

Commit 23b9bf6

Browse files
authored
Merge pull request #1203 from TanF12/fix-linux-nohup-shutdown
Fix Linux server deadlock on shutdown without TTY
2 parents 5701ff8 + f25b6b4 commit 23b9bf6

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

Server/Components/Console/console_impl.hpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class ConsoleComponent final : public IConsoleComponent, public CoreEventHandler
5656
{
5757
std::atomic_bool valid;
5858
ConsoleComponent* component;
59+
std::atomic_bool isRunning;
5960
};
6061

6162
ICore* core = nullptr;
@@ -211,7 +212,7 @@ class ConsoleComponent final : public IConsoleComponent, public CoreEventHandler
211212

212213
NetCode::Packet::PlayerRconCommand::addEventHandler(*core, &playerRconCommandHandler);
213214

214-
threadData = new ThreadProcData { true, this };
215+
threadData = new ThreadProcData { true, this, true };
215216
cinThread = std::thread(ThreadProc, threadData);
216217
nativeThreadHandle = cinThread.native_handle();
217218
cinThread.detach();
@@ -249,6 +250,7 @@ class ConsoleComponent final : public IConsoleComponent, public CoreEventHandler
249250
}
250251
else
251252
{
253+
threadData->isRunning = false;
252254
return;
253255
}
254256
}
@@ -266,7 +268,10 @@ class ConsoleComponent final : public IConsoleComponent, public CoreEventHandler
266268
cinThread.join();
267269
}
268270
#else
269-
pthread_cancel(nativeThreadHandle);
271+
if (threadData->isRunning)
272+
{
273+
pthread_cancel(nativeThreadHandle);
274+
}
270275
#endif
271276

272277
delete threadData;

Server/Components/Pawn/Plugin/Plugin.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88

99
#include "Plugin.h"
10+
#include <cstdarg>
1011
#include "../Manager/Manager.hpp"
1112

1213
#ifdef WIN32

0 commit comments

Comments
 (0)