BUG-135 - Harden Final RC1 Runtime Stabilization Edges¶
Summary¶
Fix the concrete RC1 stabilization findings selected after the final hot-path C++ review. The fixes address completion shutdown ordering, runtime NAT mapping fallback hangs, accepted TCP socket allocation cleanup, server socket create failure cleanup, and bounded Arr compatibility search cache retention.
Findings Addressed¶
- Part-file completion workers could move a completed file and delete
.part.metbefore the UI thread appliedTM_FILECOMPLETED, while shutdown savedknown.metfirst. - UPnP/PCP/NAT-PMP timeout fallback still used an unbounded owner-lifetime wait outside process shutdown, allowing the UI thread to hang on a stuck gateway or third-party NAT library call.
- Conditional TCP accept owned a raw accepted
SOCKETbefore allocating theCClientReqSocketwrapper, so low-memory allocation failure could leak the accepted handle. - Server connect ignored
Create()failure beforeConnectTo(), leaving retry and cleanup paths to reason about a socket that never entered the async connect state. - Arr-compatible search caching expired entries only when the same key was queried again, allowing cold stale result vectors to accumulate over long controller sessions.
Acceptance Criteria¶
- [x] Shutdown drains part-file completion workers and pumps posted completion
finalization before
known.metpersistence starts. - [x] Runtime NAT mapping timeout/fallback uses a bounded owner-lifetime wait, abandons stuck discovery owners instead of blocking the UI, suppresses stale worker result posts, and starts fallback attempts with a fresh timeout.
- [x] Accepted raw TCP sockets are closed if client socket wrapper allocation fails.
- [x] Server socket
Create()failure is logged, removed from open-socket tracking, and routed through the appropriate retry/stop path immediately. - [x] Arr compatibility cache purges expired entries on store and enforces a hard entry cap.
Implementation Evidence¶
d64b1c15BUG-135 drain completions before known saved5bc2a0dBUG-135 bound UPnP fallback waits967d69a8BUG-135 close accepted sockets on wrapper allocation failure20a5001bBUG-135 clean up failed server socket creation7e1cb1faBUG-135 bound Arr compatibility cache
Validation Evidence¶
git diff --check- Source normalization scan for touched app files.
- Debug x64 app build through
python -m emule_workspace build app --variant main --config Debug --platform x64 --build-output-mode ErrorsOnlyat20260529T100546Z-build-app. - Release x64 app build through
python -m emule_workspace build app --variant main --config Release --platform x64 --build-output-mode ErrorsOnlyat20260529T100556Z-build-app.