From f865361c8d69b7ca2e94837af0626ba8f290e9d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 28 Oct 2026 13:40:37 +0100 Subject: [PATCH] sceNetResolver: A lookup takes 5 ms, as on hardware sceNetResolverStartNtoA returned at once, but on a PSP a lookup through the access point takes 4-18 ms (pspautotests net/inet/timing), with the thread asleep waiting for the answer, so the game's other threads run. It now takes 5 ms and lets them. The host lookup itself is still synchronous, and stops the emulator while it waits. Co-Authored-By: Claude Opus 5.5 --- Core/HLE/sceNetResolver.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Core/HLE/sceNetResolver.cpp b/Core/HLE/sceNetResolver.cpp index 1743b0123d..00a03a35aa 100644 --- a/Core/HLE/sceNetResolver.cpp +++ b/Core/HLE/sceNetResolver.cpp @@ -138,6 +138,12 @@ static int NetResolver_StartNtoA(NetResolver *resolver, u32 hostnamePtr, u32 inA return 0; } +// A PSP takes 4-18 ms to look a name up through its access point (pspautotests net/inet/timing), the +// thread sleeping while it waits for the answer, so other threads run. +static const int RESOLVER_LOOKUP_US = 5000; + +// TODO: The host lookup still stops the whole emulator while it waits, for seconds if the DNS server is +// slow. It could run on a worker thread, with the game's thread waiting in emulated time. static int sceNetResolverStartNtoA(int resolverId, u32 hostnamePtr, u32 inAddrPtr, int timeout, int retry) { auto iter = g_netResolvers.find(resolverId); if (iter == g_netResolvers.end()) { @@ -151,10 +157,10 @@ static int sceNetResolverStartNtoA(int resolverId, u32 hostnamePtr, u32 inAddrPt for (int attempt = 0; attempt < retry; ++attempt) { const int status = NetResolver_StartNtoA(&iter->second, hostnamePtr, inAddrPtr, timeout, retry); if (status >= 0) { - return hleLogDebugOrError(Log::sceNet, status); + return hleDelayResult(hleLogDebugOrError(Log::sceNet, status), "resolver lookup", RESOLVER_LOOKUP_US); } } - return hleLogError(Log::sceNet, -1); + return hleDelayResult(hleLogError(Log::sceNet, -1), "resolver lookup", RESOLVER_LOOKUP_US); } static int sceNetResolverStartNtoAAsync(int resolverId, u32 hostnamePtr, u32 inAddrPtr, int timeout, int retry) {