From 4e6aa809de4fcad3c5e239da8c443003366f7788 Mon Sep 17 00:00:00 2001 From: Mr_Goldberg Date: Mon, 13 Jan 2020 13:47:47 -0500 Subject: [PATCH] Kill background thread on client shutdown. --- dll/steam_client.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/dll/steam_client.cpp b/dll/steam_client.cpp index a06834a..6a9725a 100644 --- a/dll/steam_client.cpp +++ b/dll/steam_client.cpp @@ -18,16 +18,21 @@ #include "steam_client.h" #include "settings_parser.h" - +static bool kill_background_thread; static void background_thread(Steam_Client *client) { PRINT_DEBUG("background thread starting\n"); while (1) { std::this_thread::sleep_for(std::chrono::seconds(1)); global_mutex.lock(); - if (!client->network->isAlive()) { + bool net_alive = client->network->isAlive(); + if (!net_alive || kill_background_thread) { global_mutex.unlock(); - //delete network; + if (!net_alive) { + //delete network; + } + + kill_background_thread = false; PRINT_DEBUG("background thread exit\n"); return; } @@ -701,6 +706,7 @@ void Steam_Client::SetWarningMessageHook( SteamAPIWarningMessageHook_t pFunction bool Steam_Client::BShutdownIfAllPipesClosed() { PRINT_DEBUG("BShutdownIfAllPipesClosed\n"); + kill_background_thread = true; return true; }