Do not clear a static variable

This commit is contained in:
Diavolo 2022-08-10 12:48:06 +02:00
parent 507833b68a
commit 422074ecee
No known key found for this signature in database
GPG Key ID: FA77F074E98D98A5
3 changed files with 4 additions and 15 deletions

View File

@ -11,7 +11,7 @@ namespace Main
#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) #if defined(DEBUG) || defined(FORCE_UNIT_TESTS)
if (Components::Loader::IsPerformingUnitTests()) if (Components::Loader::IsPerformingUnitTests())
{ {
DWORD result = (Components::Loader::PerformUnitTests() ? 0 : -1); auto result = (Components::Loader::PerformUnitTests() ? 0 : -1);
Components::Loader::Uninitialize(); Components::Loader::Uninitialize();
ExitProcess(result); ExitProcess(result);
} }
@ -26,7 +26,6 @@ namespace Main
void Uninitialize() void Uninitialize()
{ {
Components::Loader::Uninitialize(); Components::Loader::Uninitialize();
Utils::Cache::Uninitialize();
google::protobuf::ShutdownProtobufLibrary(); google::protobuf::ShutdownProtobufLibrary();
} }
@ -45,13 +44,10 @@ namespace Main
} }
} }
BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD ul_reason_for_call, LPVOID /*lpReserved*/) BOOL APIENTRY DllMain(HINSTANCE /*hinstDLL*/, DWORD fdwReason, LPVOID /*lpvReserved*/)
{ {
if (ul_reason_for_call == DLL_PROCESS_ATTACH) if (fdwReason == DLL_PROCESS_ATTACH)
{ {
// Not sure if it conflicts with our TLS variables
//DisableThreadLibraryCalls(hModule);
Steam::Proxy::RunMod(); Steam::Proxy::RunMod();
#ifndef DISABLE_BINARY_CHECK #ifndef DISABLE_BINARY_CHECK
@ -75,7 +71,7 @@ BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD ul_reason_for_call, LPVOID /*l
// Install entry point hook // Install entry point hook
Utils::Hook(0x6BAC0F, Main::EntryPoint, HOOK_JUMP).install()->quick(); Utils::Hook(0x6BAC0F, Main::EntryPoint, HOOK_JUMP).install()->quick();
} }
else if (ul_reason_for_call == DLL_PROCESS_DETACH) else if (fdwReason == DLL_PROCESS_DETACH)
{ {
Main::Uninitialize(); Main::Uninitialize();
} }

View File

@ -48,10 +48,4 @@ namespace Utils
return Utils::WebIO(useragent, Cache::GetUrl(Cache::ValidUrl, path)).setTimeout(timeout)->get(); return Utils::WebIO(useragent, Cache::GetUrl(Cache::ValidUrl, path)).setTimeout(timeout)->get();
} }
} }
void Cache::Uninitialize()
{
std::lock_guard<std::mutex> _(Cache::CacheMutex);
Cache::ValidUrl.clear();
}
} }

View File

@ -7,7 +7,6 @@ namespace Utils
public: public:
static std::string GetStaticUrl(const std::string& path); static std::string GetStaticUrl(const std::string& path);
static std::string GetFile(const std::string& path, int timeout = 5000, const std::string& useragent = "IW4x"); static std::string GetFile(const std::string& path, int timeout = 5000, const std::string& useragent = "IW4x");
static void Uninitialize();
private: private:
static std::mutex CacheMutex; static std::mutex CacheMutex;