network: handle SO_NBIO on non-Windows hosts #954

Manually merged
github merged 3 commits from gh-pr/954/head into gh-pr/954/base 2026-11-26 09:38:03 +00:00
Owner

@⁠Aryansh1520 on GitHub · 2026-10-01 09:30 UTC · original
Aryansh1520:fix/linux-socket-nbio → main · +29 −7 · 1 files · 3 commits · merged 2026-10-01 13:54 UTC

Problem

Setsockopt only translated the guest SOL_SOCKET/SO_NBIO (0x1200) option under _WIN32. On Linux/macOS it fell through to the TCP-only path and returned ENOPROTOOPT.

God of War Sons of Sparta (PPSA28997) initialises FMOD Studio with FMOD_STUDIO_INIT_LIVEUPDATE. The Live Update listener sets SO_NBIO on its socket; when that fails, the Studio async manager latches FMOD_ERR_NET_CONNECT, and every blocking Studio call afterwards fails. All eight loadBankFile calls returned FMOD_ERR_NOTREADY, so on Linux:

  • no audio at all (no bank ever loaded, including the boot logos), and
  • a permanent black screen after the loading screen: the splash screen waits on FMODUnity.RuntimeManager.HaveAllBanksLoaded, whose counter stays at 8.

Fix

Handle SO_NBIO on every host: ioctlsocket(FIONBIO) on Windows (unchanged), fcntl toggling O_NONBLOCK elsewhere (the same mechanism Socket already uses for P2P sockets).

Testing

  • Linux (CachyOS, RTX 5060 Laptop): PPSA28997 now boots to the main menu and plays normally into gameplay with audio; previously black screen + silence after the loading screen.
  • Windows path is behaviourally unchanged (variable renamed only).
  • Follow-up commit maps the remaining POSIX connection errors (EINPROGRESS, EALREADY, ECONNREFUSED, ...) that previously reached the guest as EIO; this path becomes reachable once guests can enable nonblocking mode.
**@⁠Aryansh1520** on GitHub · 2026-10-01 09:30 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/954) `Aryansh1520:fix/linux-socket-nbio` → `main` · +29 −7 · 1 files · 3 commits · merged 2026-10-01 13:54 UTC ## Problem `Setsockopt` only translated the guest `SOL_SOCKET`/`SO_NBIO` (`0x1200`) option under `_WIN32`. On Linux/macOS it fell through to the TCP-only path and returned `ENOPROTOOPT`. God of War Sons of Sparta (PPSA28997) initialises FMOD Studio with `FMOD_STUDIO_INIT_LIVEUPDATE`. The Live Update listener sets `SO_NBIO` on its socket; when that fails, the Studio async manager latches `FMOD_ERR_NET_CONNECT`, and every blocking Studio call afterwards fails. All eight `loadBankFile` calls returned `FMOD_ERR_NOTREADY`, so on Linux: - no audio at all (no bank ever loaded, including the boot logos), and - a permanent black screen after the loading screen: the splash screen waits on `FMODUnity.RuntimeManager.HaveAllBanksLoaded`, whose counter stays at 8. ## Fix Handle `SO_NBIO` on every host: `ioctlsocket(FIONBIO)` on Windows (unchanged), `fcntl` toggling `O_NONBLOCK` elsewhere (the same mechanism `Socket` already uses for P2P sockets). ## Testing - Linux (CachyOS, RTX 5060 Laptop): PPSA28997 now boots to the main menu and plays normally into gameplay with audio; previously black screen + silence after the loading screen. - Windows path is behaviourally unchanged (variable renamed only). - Follow-up commit maps the remaining POSIX connection errors (`EINPROGRESS`, `EALREADY`, `ECONNREFUSED`, ...) that previously reached the guest as `EIO`; this path becomes reachable once guests can enable nonblocking mode.
Setsockopt only translated the guest SOL_SOCKET/SO_NBIO (0x1200) option
under _WIN32; other hosts rejected it with ENOPROTOOPT. FMOD Studio's Live
Update listener sets SO_NBIO, so on Linux its socket setup failed and the
Studio async manager latched FMOD_ERR_NET_CONNECT. Every blocking Studio
call then failed: loadBankFile returned FMOD_ERR_NOTREADY for all banks,
leaving the game silent and stuck on the splash screen waiting for
RuntimeManager.HaveAllBanksLoaded (PPSA28997).

Toggle O_NONBLOCK with fcntl on non-Windows hosts.
ConvertHostSocketError only covered a handful of errno values on
non-Windows hosts, so anything else reached the guest as EIO. With
SO_NBIO now honoured there, a nonblocking connect() that is still in
progress returned EIO instead of EINPROGRESS (and EALREADY on retry).

Map the same connection and network errors the Windows branch already
translates.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:38:02 +00:00
github manually merged commit 447188cd35 into gh-pr/954/base 2026-11-26 09:38:03 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-01 09:34 UTC · original · edited 2026-10-01 09:57 UTC

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: ab85b3ed-170d-404d-86cb-2435544c7838

📥 Commits

Reviewing files that changed from the base of the PR and between 7a784dad96 and 9905e55489.

📒 Files selected for processing (1)
  • src/libs/network.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.


📝 Walkthrough

Walkthrough

On non-Windows systems, ConvertHostSocketError maps additional host socket errors to guest POSIX errors. Setsockopt handles ORBIS_SO_NBIO on Windows and POSIX systems. Windows uses ioctlsocket; POSIX uses fcntl to set or clear O_NONBLOCK while preserving other flags. Failures return through host socket error conversion.

Suggested reviewers: nmzik

Priority: ⬆️ High

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 9905e

Pending connections and would-block results now retain their expected guest error statuses. No concrete merge-blocking risk remains; the change is ready for normal checks.

Security Architecture Review

Security architecture risk: ⚪ Minimal · up to 9905e

The inspected changes enable nonblocking behavior for existing sockets without adding destinations or privileges. Socket validation and lifetime protection remain intact, and no material new security risk was identified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — Guest code invoking the existing socket API can now change blocking mode on POSIX native sockets represented in the existing descriptor table. The changed code neither opens another endpoint nor selects an arbitrary host descriptor. Shared error conversion can affect multiple socket operations and SO_ERROR readers; exhaustive downstream callers remain unestablished.

Trust Boundaries and Controls

  • observed — Guest-controlled descriptor and option values reach fcntl only after bounded, occupied-slot lookup and P2P separation. The lookup is a descriptor-validity control; it does not establish a separate tenant or per-caller authorization policy.

Resilience and Maintainability Implications

  • inferred — Retained transport ownership prevents close-and-reuse from redirecting an in-flight NBIO update to a replacement socket. Sequential repeated requests converge on the requested mode. Concurrent toggles are not serialized around the read/write pair and follow host write ordering; no security-relevant identity or cleanup failure was established from the inspected paths.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the main change: handling SO_NBIO on non-Windows hosts.
Description check ✅ Passed The description is directly related to the changeset. It explains the SO_NBIO failure, the POSIX fix, the error mappings, and the reported Linux testing.
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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

Comment @coderabbitai help to get the list of available commands.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-01 09:34 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/954#issuecomment-5928739378) · edited 2026-10-01 09:57 UTC <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/954?cs_source=review_comment"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=2" alt="Review in Change Stack →" width="220" height="32"></a> Navigate logical layers of code changes, visualize relationships, and explore their blast radius. <!-- review_stack_entry_end --> <!-- recent_review_start --> No actionable comments were generated in the recent review. 🎉 <details> <summary>ℹ️ Recent review info</summary> <details> <summary>⚙️ Run configuration</summary> **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml **Review profile**: CHILL **Plan**: Advanced **Run ID**: `ab85b3ed-170d-404d-86cb-2435544c7838` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 7a784dad96a479d6bc97b5bb6e5c2f10f343bcf7 and 9905e554892114c423043dd6d12f1bf3df40ab37. </details> <details> <summary>📒 Files selected for processing (1)</summary> * `src/libs/network.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review. </details> --- <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary>📝 Walkthrough</summary> ## Walkthrough On non-Windows systems, `ConvertHostSocketError` maps additional host socket errors to guest POSIX errors. `Setsockopt` handles `ORBIS_SO_NBIO` on Windows and POSIX systems. Windows uses `ioctlsocket`; POSIX uses `fcntl` to set or clear `O_NONBLOCK` while preserving other flags. Failures return through host socket error conversion. **Suggested reviewers:** `nmzik` </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ⬆️ High <!-- change_assessment_commit:"9905e554892114c423043dd6d12f1bf3df40ab37" --> **Change:** Bug fix <!-- change_assessment_end --> <!-- final_review_risk_start --> **Merge Risk:** _⚪ Minimal_ · up to `9905e` <!-- final_review_risk_coverage:{"sourceCommitId":"9905e554892114c423043dd6d12f1bf3df40ab37","coveredCommitId":"9905e554892114c423043dd6d12f1bf3df40ab37","kind":"reviewed"} --> Pending connections and would-block results now retain their expected guest error statuses. No concrete merge-blocking risk remains; the change is ready for normal checks. <!-- final_review_risk_end --> <!-- architecture_review_start --> ### Security Architecture Review **Security architecture risk:** _⚪ Minimal_ · up to `9905e` The inspected changes enable nonblocking behavior for existing sockets without adding destinations or privileges. Socket validation and lifetime protection remain intact, and no material new security risk was identified. **Retained concerns** No architecture-level concerns identified. <details> <summary>Security review details</summary> **Security Blast Radius** - _inferred_ — Guest code invoking the existing socket API can now change blocking mode on POSIX native sockets represented in the existing descriptor table. The changed code neither opens another endpoint nor selects an arbitrary host descriptor. Shared error conversion can affect multiple socket operations and SO_ERROR readers; exhaustive downstream callers remain unestablished. **Trust Boundaries and Controls** - _observed_ — Guest-controlled descriptor and option values reach fcntl only after bounded, occupied-slot lookup and P2P separation. The lookup is a descriptor-validity control; it does not establish a separate tenant or per-caller authorization policy. **Resilience and Maintainability Implications** - _inferred_ — Retained transport ownership prevents close-and-reuse from redirecting an in-flight NBIO update to a replacement socket. Sequential repeated requests converge on the requested mode. Concurrent toggles are not serialized around the read/write pair and follow host write ordering; no security-relevant identity or cleanup failure was established from the inspected paths. </details> <!-- architecture_review_end --> <!-- pre_merge_checks_walkthrough_start --> <details> <summary>🚥 Pre-merge checks | ✅ 4 | ❌ 1</summary> ### ❌ Failed checks (1 warning) | Check name | Status | Explanation | Resolution | | :----------------: | :--------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ⚠️ Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 1 files. | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary>✅ Passed checks (4 passed)</summary> | Check name | Status | Explanation | | :------------------------: | :------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------- | | Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. | | Title check | ✅ Passed | The title clearly identifies the main change: handling SO_NBIO on non-Windows hosts. | | Description check | ✅ Passed | The description is directly related to the changeset. It explains the SO_NBIO failure, the POSIX fix, the error mappings, and the reported Linux testing. | </details> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- autopilot:start --> - [ ] <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autopilot</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts > Autopilot is currently an internal CodeRabbit preview. <!-- autopilot:end --> <!-- tips_start --> --- Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=954)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary>❤️ Share</summary> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-01 09:34 UTC · original · reviewed

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

🟠 Major · Map nonblocking connection errors on POSIX. · network.cpp:1008

src/libs/network.cpp:1008
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Map nonblocking connection errors on POSIX.

This change lets guests enable O_NONBLOCK before calling Connect. When connection establishment is pending, POSIX returns EINPROGRESS; another connection attempt returns EALREADY. (pubs.opengroup.org)

Connect passes these errors through SetHostSocketError, but this switch maps neither error. Both become POSIX_EIO, so guests receive an I/O failure instead of the pending-connection status.

Add mappings to Posix::POSIX_EINPROGRESS and Posix::POSIX_EALREADY, as the Windows branch already does.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 3ebe9f55-f661-4c85-b8da-68613c1b132b

📥 Commits

Reviewing files that changed from the base of the PR and between b7a1fac898 and 7a784dad96.

📒 Files selected for processing (1)
  • src/libs/network.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-01 09:34 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/954#pullrequestreview-5377516199) · **reviewed** > [!CAUTION] > Some comments are outside the diff and can’t be posted inline due to GitHub limitations. > > **⚠️ Outside diff range comments (1)** > > <details> > <summary><em>🟠 Major</em> · Map nonblocking connection errors on POSIX. · <code>network.cpp:1008</code></summary><blockquote> > > `src/libs/network.cpp:1008` > _🎯 Functional Correctness_ | _🟠 Major_ | _⚡ Quick win_ > > **Map nonblocking connection errors on POSIX.** > > This change lets guests enable `O_NONBLOCK` before calling `Connect`. When connection establishment is pending, POSIX returns `EINPROGRESS`; another connection attempt returns `EALREADY`. ([pubs.opengroup.org](https://pubs.opengroup.org/onlinepubs/009695399/functions/connect.html?utm_source=openai)) > > `Connect` passes these errors through `SetHostSocketError`, but this switch maps neither error. Both become `POSIX_EIO`, so guests receive an I/O failure instead of the pending-connection status. > > Add mappings to `Posix::POSIX_EINPROGRESS` and `Posix::POSIX_EALREADY`, as the Windows branch already does. > > <!-- cr-comment:v1:5b056d37c679d1e3ee7e5328 --> > > </blockquote></details> --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml **Review profile**: CHILL **Plan**: Advanced **Run ID**: `3ebe9f55-f661-4c85-b8da-68613c1b132b` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between b7a1fac898be93bfe0c282752a7a386fd5202486 and 7a784dad96a479d6bc97b5bb6e5c2f10f343bcf7. </details> <details> <summary>📒 Files selected for processing (1)</summary> * `src/libs/network.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
Author
Owner

@⁠Aryansh1520 on GitHub · 2026-10-01 09:38 UTC · original

Addressed the nonblocking-connect finding in 9905e55: the POSIX branch of ConvertHostSocketError now maps EINPROGRESS/EALREADY and the other connection errors the Windows branch already handles, instead of falling back to EIO. Re-tested PPSA28997 on Linux: still reaches the main menu with audio.

The docstring-coverage warning doesn't apply here; the surrounding networking code doesn't use docstrings.

**@⁠Aryansh1520** on GitHub · 2026-10-01 09:38 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/954#issuecomment-5928802000) Addressed the nonblocking-connect finding in 9905e55: the POSIX branch of `ConvertHostSocketError` now maps `EINPROGRESS`/`EALREADY` and the other connection errors the Windows branch already handles, instead of falling back to `EIO`. Re-tested PPSA28997 on Linux: still reaches the main menu with audio. The docstring-coverage warning doesn't apply here; the surrounding networking code doesn't use docstrings.
This discussion has been locked. Commenting is limited to contributors.
No description provided.