Implement sceNetResolverStartNtoaMultipleRecords (RCCY01Xd+58) #2027
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!2027
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2027/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Ekt0re on GitHub · 2026-10-31 18:12 UTC · original
Ekt0re:RCCY01Xd+58→main· +747 −207 · 5 files · 3 commits · closed without mergingImplement
sceNetResolverStartNtoaMultipleRecords(RCCY01Xd+58)Summary
This PR implements the missing
libSceNetexportRCCY01Xd+58(sceNetResolverStartNtoaMultipleRecords). It performs a DNS name-to-address lookup and returns all IPv4 records found for a hostname (up to 10), instead of a single address likesceNetResolverStartNtoa.To support it, the resolver code was reworked:
sceNetResolverStartNtoaand the new export now share one internal implementation, andsceNetResolverAbortis no longer a no-op.Background
HOT WHEELS™ Infinite Rush (PPSA22408) calls this function and currently stops at the logo screen:
The behavior was modeled on the shadPS4 implementation (
net.cpp,net_resolver.cpp,net_resolver.h) and adapted to KytyPS5's existingNetworkclass.https://git.gtahub.st/github/KytyPS5--KytyPS5/issues/1960
Changes
Export and registration (
src/libs/libNet.cpp)LibNet::NetResolverStartNtoaMultipleRecords(rid, hostname, info, timeout, retry, flags), wrapped withFinishNetCall.RCCY01Xd+58inInitNet_1_Net.Public types and declarations (
src/libs/network.h)NetResolverAddress(36 bytes) andNetResolverInfo(384 bytes, up to 10 addresses), both guarded bystatic_asserton their size.NetResolverStartNtoaMultipleRecords.Resolver state (
src/libs/network.cpp)The
Resolverstruct gainedrunning,abort_requested,last_errorandgeneration. Four newNetworkmethods manage it:ResolverAbortNET_ERROR_EINTR), bumps the generation and clearsrunning.ResolverBeginLookupEBADF), a busy resolver (NET_ERROR_RESOLVER_EBUSY) and a queued abort (EINTR, consumed). Otherwise marks the resolver running and returns a new generation.ResolverEndLookupResolverCheckValidForDeliveryResolverDestroynow carries the generation forward so a late async lookup cannot match a recycled slot.Lookup logic (
src/libs/network.cpp)NetResolverStartNtoaand the new export both callResolverStartNtoaInternal:NET_ERROR_EBADF; null hostname or no output buffer →NET_ERROR_EINVAL; empty hostname or longer than 255 characters →NET_ERROR_EINVAL..is stripped.localhostresolves to127.0.0.1.ORBIS_NET_RESOLVER_START_NTOA_DISABLE_IPADDRESS(0x00010000) is set.getaddrinforuns withAF_INET/SOCK_STREAM. Results are deduplicated and capped at 10.NetResolverInfois zeroed, thenrecordsandrecordsv4are set to the address count and each entry getsaf = 2(AF_INET). ForsceNetResolverStartNtoa, only the first address is written.ORBIS_NET_RESOLVER_ASYNC,0x00000001): the work runs on a detached thread and the call returns0immediately. The result is written only ifResolverCheckValidForDeliverystill holds.Error translation from
getaddrinfo(including the WindowsWSA*equivalents):EAI_NONAME,EAI_NODATANET_ERROR_RESOLVER_ENOHOSTEAI_AGAINNET_ERROR_RESOLVER_ETIMEDOUTEAI_FAILNET_ERROR_RESOLVER_ESERVERFAILURENET_ERROR_RESOLVER_ENORECORDNET_ERROR_RESOLVER_EINTERNALsceNetResolverAbortPreviously it only logged and returned
OK. It now returnsNET_ERROR_EBADFfor an unknown resolver, and otherwise aborts the running lookup or queues the abort for the next one.Tests
tests/NetResolverTests.cppand thenet_resolver_teststarget inCMakeLists.txt.localhost(including trailing dot), literal IP with and withoutDISABLE_IPADDRESS, abort followed by a successful lookup, an async lookup, and a real resolution ofgoogle.com.Behavior changes to existing code
These affect
sceNetResolverStartNtoaas well, because it now uses the shared path:EBADFinstead ofEINVAL.flagsargument is no longer rejected when it contains bits other than0x00010000.ORBIS_NET_RESOLVER_ASYNCis now honored.NET_ERROR_RESOLVER_ENODNSinstead ofNET_ERROR_ENETDOWN.localhosthandling and the 10-record cap apply tosceNetResolverStartNtoaas well.Known limitations
timeoutandretryare only logged, not enforced.recordsv6stays0.sceNetResolverStartNtoaMultipleRecordsEx,ResolverGetErrorandResolverStartAtonare not part of this PR.localhost(for examplelocalhost.example.com) resolves to127.0.0.1.Formatting
The diff also contains whitespace-only changes in
libNet.cppandnetwork.cpp(alignment and line wrapping from the formatter). They do not change behavior.Testing
net_resolver_testsbuilds and passesTestResolveGoogleneeds working DNS and network access; run it on a machine that is onlineRCCY01Xd+58importAI use:
AI was used to analyze the problem and explore possible solutions.
I performed the testing manually.
@coderabbitai[bot] on GitHub · 2026-10-31 18:24 UTC · original · edited 2026-10-31 22:24 UTC
Walkthrough
The change adds a multiple-record resolver API with synchronous and asynchronous IPv4 lookup, hostname validation, and generation-based abort and delivery checks. Resolver results hold up to 10 addresses. Network, SSL, and HTTP entry points now use a mutex-protected shared
Networkinstance. The change also includes formatting changes and a test executable for resolver behavior.Suggested reviewers:
nmzikChange: Feature
Merge Risk:
Low · up to
74e1cThe resolver test should synchronize result publication before reading asynchronous output; otherwise test results may be unreliable.
Pre-merge checks:
4 ·
1
Full details: Title check
Explanation
The title names the main change: adding the libSceNet export sceNetResolverStartNtoaMultipleRecords (RCCY01Xd+58). The changeset registers this export in libNet.cpp, declares it in network.h, and implements it in network.cpp. The title is specific and matches the primary change.
Full details: Description check
Explanation
The description is directly related to the changeset. It names the new export, explains the shared resolver implementation, lists the public types and resolver state methods, describes the tests, and documents behavior changes and known limitations. This matches the files in the raw summary.
Full details: Docstring Coverage
Explanation
Docstring coverage is 1.28% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 78 functions across 4 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Share
@ -1461,0 +1611,4 @@const int begin_ret = network->ResolverBeginLookup(rid, is_async, &generation);if (begin_ret != 0) {return begin_ret;}@coderabbitai[bot] on GitHub · 2026-10-31 18:24 UTC · original · edited 2026-10-31 21:45 UTC
Validate flags before delegating
NetResolverStartNtoa.NetResolverStartNtoapreviously returnedNET_ERROR_EINVALfor flags other than0x00010000. It now delegates directly toResolverStartNtoaInternal, where0x00000001enables asynchronous lookup. A reachable guest call withflags = 0x1can therefore returnOKand start a detached lookup instead of rejecting the invalid flags. Preserve async handling for the multiple-record API, but validate flags separately inNetResolverStartNtoa.Suggested fix
✅ Addressed in commit
b086a5d@coderabbitai[bot] on GitHub · 2026-10-31 18:24 UTC · original · edited 2026-10-31 21:45 UTC
On
src/libs/network.cppline 1591 (outdated):Fix the
localhostmatch. It currently matches any hostname that starts withlocalhost.host.rfind("localhost", 0) == 0is a prefix test. Hostnames such aslocalhost.example.comorlocalhost-api.example.comresolve to127.0.0.1and skip DNS. The check also ignores case, soLOCALHOSTgoes to DNS. Use a case-insensitive equality test.🐛 Proposed fix
✅ Addressed in commit
b086a5d@ -1461,0 +1718,4 @@for (size_t i = 0; i < count; ++i) {out.info->addrs[i].af = 2; // ORBIS_NET_AF_INETout.info->addrs[i].u.addr.inaddr_addr = addrs[i];}@coderabbitai[bot] on GitHub · 2026-10-31 18:24 UTC · original · edited 2026-10-31 21:45 UTC
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 8034
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 41540
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 26300
Publish the address records before the counts.
deliver_resultwritesrecordsandrecordsv4beforeaddrs[]. The async test pollsrecordsand then readsaddrs[0], so it can observe an incomplete result.Reorder the writes. A release fence alone is not a synchronization protocol because the reader has no matching acquire operation.
♻️ Suggested reorder
If the guest contract requires a formal cross-thread guarantee, add a completion mechanism with a matching acquire operation. Do not rely on the release fence alone.
Committable suggestion
✅ Addressed in commit
b086a5d@ -1461,0 +1741,4 @@return res;}return NET_ERROR_EINTR;}@coderabbitai[bot] on GitHub · 2026-10-31 18:24 UTC · original · edited 2026-10-31 21:45 UTC
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 7980
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 6566
Serialize synchronous delivery with generation validation.
NetResolverAbortcan invalidate the generation whiledo_lookupruns. The synchronous branch then callsdeliver_resultwithout validation and returns the originalres, so an aborted successful lookup can write stale records and returnOK.Do not add a separate
ResolverCheckValidForDeliverycall beforedeliver_result; that method releasesm_mutexbefore the write. Add aNetworkhelper that holdsm_mutexwhile it validates the resolver generation and invokesdeliver_result. Skip the write and returnNET_ERROR_EINTRwhen the generation is invalid. Pass that result toResolverEndLookupand return it. Keep this correction limited to the synchronous branch.✅ Addressed in commit
b086a5d@coderabbitai[bot] on GitHub · 2026-10-31 18:24 UTC · original · edited 2026-10-31 21:46 UTC
On
src/libs/network.cppline 1710 (outdated):Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 29085
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 3314
Synchronize the shared-pointer handoff.
A plain
const auto network = g_netstill racesShutdown()resettingg_net. Protect the handoff with the existing mutex pattern, then capture the local owner in the worker. Apply the accessor to eachg_netread that can overlap shutdown.Suggested fix
✅ Addressed in commit
b086a5d@coderabbitai[bot] on GitHub · 2026-10-31 18:24 UTC · original · edited 2026-10-31 21:45 UTC
On
src/libs/network.cppline 1708 (outdated):Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 10958
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 7399
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 7170
Serialize async delivery with resolver abort.
ResolverCheckValidForDeliveryreleasesm_mutexbeforedeliver_result.ResolverAbortcan invalidate the generation and return before the worker writes to the guest buffer. Run the delivery callback while the validity check still holdsm_mutex.Suggested fix
✅ Addressed in commit
b086a5d@coderabbitai[bot] on GitHub · 2026-10-31 18:24 UTC · original · edited 2026-10-31 21:45 UTC
On
tests/NetResolverTests.cppline 130 (outdated):Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 8459
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 11161
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 40701
Join the async resolver worker before releasing
info.The
google.comlookup is not part of the default CTest workflow becausenet_resolver_testsis excluded from the default build and has noadd_testentry. An explicit run of the executable still requires live DNS.The async lookup uses a detached worker. The 500 ms poll does not join it, and
Shutdown()does not wait for it. The worker can therefore write throughinfoafterTestLocalhostAndLiteralIpreleases its stack frame. Wait for worker completion before teardown, or use storage that outlives the worker.✅ Addressed in commit
b086a5d@coderabbitai[bot] on GitHub · 2026-10-31 18:24 UTC · original · reviewed
Actionable comments posted: 7
575e74c1-1e83-439a-b6e7-ba18c02de5fcReviewing files that changed from the base of the PR and between
026189166fandb39bda218d.CMakeLists.txtsrc/libs/libNet.cppsrc/libs/network.cppsrc/libs/network.htests/NetResolverTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
@coderabbitai[bot] on GitHub · 2026-10-31 21:49 UTC · original · edited 2026-10-31 22:14 UTC
On
src/libs/network.cppline 1739 (outdated):Check cancellation before returning a synchronous DNS error.
If
NetResolverAbortinvalidates a synchronous lookup whilegetaddrinfois running, a failed DNS lookup reaches this branch.ResolverEndLookupignores the stale generation, but the call still returns the DNS error instead ofNET_ERROR_EINTR. Apply the generation check to failed lookups too, then end the lookup and return the resulting error. (raw.githubusercontent.com)✅ Addressed in commit
74e1c9b@coderabbitai[bot] on GitHub · 2026-10-31 21:49 UTC · original · reviewed
Follow-up Comments
f60a259b-4ed4-4b1c-83f7-b528e81008e0Reviewing files that changed from the base of the PR and between
b39bda218dandb086a5dbc8.src/libs/network.cpptests/NetResolverTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
@coderabbitai[bot] on GitHub · 2026-10-31 22:24 UTC · original · reviewed
Follow-up Comments
a957bf2b-f7cd-451b-aa98-def517025b99Reviewing files that changed from the base of the PR and between
b086a5dbc8and74e1c9b976.src/libs/network.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
@Nmzik on GitHub · 2026-10-31 23:34 UTC · original
Credited
Pull request closed