BUG-137 - Harden Final RC1 AICH, UPnP, Listener, And Kad Edges¶
Summary¶
Fix the concrete RC1 stabilization findings selected from the final C++ hot-path review. The changes focus on AICH sync lifetime and startup cost, stale UPnP worker results, truthful TCP listener state, accept-loop low-memory behavior, and Kad partial startup cleanup.
Findings Addressed¶
- AICH sync hashed whole shared files while holding the shared-file write lock and could publish stale metadata after a rescan or shutdown transition.
- A stale UPnP worker result could arrive after fallback and act on the active backend rather than the backend which produced the result.
- TCP listener startup could leave
bListeningtrue after socket creation succeeded butlisten()failed. - Normal TCP accept allocation failure skipped wrapper creation before draining the pending kernel backlog item.
- Kad startup could leave a partial singleton allocated after mid-start allocation failure, wedging later starts in the same process.
Acceptance Criteria¶
- [x] AICH sync hashes outside the shared-file write lock and applies results only if the live shared file still matches the snapped identity.
- [x] UPnP results carry their originating backend and stale results are ignored.
- [x] TCP listener state becomes active only after
listen()succeeds. - [x] Normal accept allocation failure accept-and-closes one pending socket to prevent a tight retry loop on the same backlog item.
- [x] Kad startup owns partial allocations locally until all required objects are constructed and the singleton is ready to publish.
Implementation Evidence¶
39933d81BUG-137 separate AICH sync hashing from metadata publish63c2ae63BUG-137 ignore stale UPnP backend resultse4c1d752BUG-137 keep TCP listener state truthful9b38fd1eBUG-137 clean up partial Kad startup
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 ErrorsOnlyat20260529T105926Z-build-app. - Release x64 app build through
python -m emule_workspace build app --variant main --config Release --platform x64 --build-output-mode ErrorsOnlyat20260529T105933Z-build-app.