Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Server/Components/Console/console_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class ConsoleComponent final : public IConsoleComponent, public CoreEventHandler
String cmd;
ThreadProcData* threadData;
std::thread cinThread;
std::thread::native_handle_type nativeThreadHandle;

struct PlayerRconCommandHandler : public SingleNetworkInEventHandler
{
Expand Down Expand Up @@ -212,7 +213,11 @@ class ConsoleComponent final : public IConsoleComponent, public CoreEventHandler

threadData = new ThreadProcData { true, this };
cinThread = std::thread(ThreadProc, threadData);
nativeThreadHandle = cinThread.native_handle();

#ifndef WIN32
cinThread.detach();
#endif
}

void onReady() override
Expand Down Expand Up @@ -257,10 +262,16 @@ class ConsoleComponent final : public IConsoleComponent, public CoreEventHandler
if (threadData)
{
threadData->valid = false;

#ifdef WIN32
if (cinThread.joinable())
{
cinThread.join();
}
#else
pthread_cancel(nativeThreadHandle);
#endif

delete threadData;
threadData = nullptr;
}
Expand Down