diff --git a/Common/Net/Resolve.cpp b/Common/Net/Resolve.cpp index bc52b912ac..e43192ee9d 100644 --- a/Common/Net/Resolve.cpp +++ b/Common/Net/Resolve.cpp @@ -31,7 +31,6 @@ extern JavaVM *gJvm; namespace net { -static bool g_naettInitialized; static bool g_wsaInitialized; void Init() { @@ -44,19 +43,18 @@ void Init() { g_wsaInitialized = true; } #endif - if (!g_naettInitialized) { + // naett ignores repeat calls the same way WSAStartup does, so there's nothing to track here + // either. HTTPSAvailable is cheap to ask twice - on Linux it's a cached dlopen result. #ifndef HTTPS_NOT_AVAILABLE #if PPSSPP_PLATFORM(ANDROID) - _assert_(gJvm != nullptr); - naettInit(gJvm); + _assert_(gJvm != nullptr); + naettInit(gJvm); #else - if (HTTPSAvailable()) { - naettInit(NULL); - } -#endif -#endif - g_naettInitialized = true; + if (HTTPSAvailable()) { + naettInit(NULL); } +#endif +#endif } bool HTTPSAvailable() { diff --git a/ext/naett-lib/README-ppsspp.md b/ext/naett-lib/README-ppsspp.md index b0612eb6fb..008b7262fb 100644 --- a/ext/naett-lib/README-ppsspp.md +++ b/ext/naett-lib/README-ppsspp.md @@ -116,3 +116,6 @@ Keep this list up to date - it's what makes it possible to move to a newer upstr release build that walked into a null dereference. Returns NULL instead. - `src/naett_osx.c`: the delegate callbacks ignore a response that's already complete, so a cancellation we asked for doesn't overwrite the error that caused it. +- `src/naett_core.c` / `naett.h`: `naettInit` asserted it was only ever called once, so a caller + that can be entered more than again needed a flag purely to guard it. A repeat call is a no-op + now, the way `WSAStartup` behaves, and `net::Init` dropped its `g_naettInitialized`. diff --git a/ext/naett-lib/naett.h b/ext/naett-lib/naett.h index 67716a0626..7d6102671d 100644 --- a/ext/naett-lib/naett.h +++ b/ext/naett-lib/naett.h @@ -17,6 +17,10 @@ typedef void* naettInitData; /** * @brief Global init method. * Call to initialize the library. + * + * PPSSPP: calling this more than once is fine - everything after the first call does nothing, + * including the platform setup, so the init data from the first call is the one that sticks. + * Not thread safe; call it during startup, before anything else can reach the library. */ void naettInit(naettInitData initThing); diff --git a/ext/naett-lib/src/naett_core.c b/ext/naett-lib/src/naett_core.c index b6f4efc8c3..7140beaebd 100644 --- a/ext/naett-lib/src/naett_core.c +++ b/ext/naett-lib/src/naett_core.c @@ -137,7 +137,12 @@ static void applyOptionParams(InternalRequest* req, InternalOption* option) { // Public API void naettInit(naettInitData initData) { - assert(!initialized); + // PPSSPP: upstream asserted that this was the first call. Callers that can be entered more + // than once then need a flag of their own purely to guard this, which is bookkeeping the + // library may as well do itself - so a repeat call is a no-op instead. + if (initialized) { + return; + } naettPlatformInit(initData); initialized = 1; }