From cbf24a9d7863ae6c6826d1e2f4eaf7eafa1b4816 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Tue, 14 Feb 2017 13:11:46 +0100 Subject: [PATCH] Get rid of "AutoInit", instead always keep the network initialized. See #9305 --- Core/FileLoaders/HTTPFileLoader.h | 1 - Core/Reporting.cpp | 1 - UI/RemoteISOScreen.cpp | 1 - Windows/main.cpp | 4 +++- ext/native/net/http_client.cpp | 1 - ext/native/net/resolve.h | 9 --------- 6 files changed, 3 insertions(+), 14 deletions(-) diff --git a/Core/FileLoaders/HTTPFileLoader.h b/Core/FileLoaders/HTTPFileLoader.h index 38acb461ed..5e92877a74 100644 --- a/Core/FileLoaders/HTTPFileLoader.h +++ b/Core/FileLoaders/HTTPFileLoader.h @@ -65,7 +65,6 @@ private: s64 filesize_; s64 filepos_; Url url_; - net::AutoInit netInit_; http::Client client_; std::string filename_; bool connected_; diff --git a/Core/Reporting.cpp b/Core/Reporting.cpp index 22a640fde3..cbe150e2b3 100644 --- a/Core/Reporting.cpp +++ b/Core/Reporting.cpp @@ -217,7 +217,6 @@ namespace Reporting bool SendReportRequest(const char *uri, const std::string &data, const std::string &mimeType, Buffer *output = NULL) { bool result = false; - net::AutoInit netInit; http::Client http; Buffer theVoid; diff --git a/UI/RemoteISOScreen.cpp b/UI/RemoteISOScreen.cpp index 48435ed598..7bef93c999 100644 --- a/UI/RemoteISOScreen.cpp +++ b/UI/RemoteISOScreen.cpp @@ -81,7 +81,6 @@ static void RegisterServer(int port) { static void ExecuteServer() { setCurrentThreadName("HTTPServer"); - net::AutoInit netInit; auto http = new http::Server(new threading::SameThreadExecutor()); std::map paths; diff --git a/Windows/main.cpp b/Windows/main.cpp index 3b6a10a307..d22a1c0082 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -32,6 +32,7 @@ #include "profiler/profiler.h" #include "thread/threadutil.h" #include "util/text/utf8.h" +#include "net/resolve.h" #include "Core/Config.h" #include "Core/SaveState.h" @@ -294,7 +295,7 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin setCurrentThreadName("Main"); CoInitializeEx(NULL, COINIT_MULTITHREADED); - + net::Init(); #ifdef _DEBUG _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); #endif @@ -528,6 +529,7 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin W32Util::ExitAndRestart(); } + net::Shutdown(); CoUninitialize(); return 0; diff --git a/ext/native/net/http_client.cpp b/ext/native/net/http_client.cpp index b4fdb82fe8..cb652d93be 100644 --- a/ext/native/net/http_client.cpp +++ b/ext/native/net/http_client.cpp @@ -401,7 +401,6 @@ void Download::Do(std::shared_ptr self) { SetFailed(-1); return; } - net::AutoInit netInit; http::Client client; if (!client.Resolve(fileUrl.Host().c_str(), fileUrl.Port())) { diff --git a/ext/native/net/resolve.h b/ext/native/net/resolve.h index 7de2c1c66f..46a8b3e598 100644 --- a/ext/native/net/resolve.h +++ b/ext/native/net/resolve.h @@ -10,15 +10,6 @@ namespace net { void Init(); void Shutdown(); -struct AutoInit { - AutoInit() { - Init(); - } - ~AutoInit() { - Shutdown(); - } -}; - // use free() to free the returned string. char *DNSResolveTry(const char *host, const char **err); char *DNSResolve(const char *host);