Skip to content

BUG-126 - Harden Transfer Queue Async Lifetime Edges

Summary

Fix the remaining active transfer lifetime hazards found during the follow-up review of CUpDownClient, upload queues, download queues, A4AF lists, and part-file async I/O.

Findings To Address

  • Upload disk read completions can still touch CKnownFile state after the pending-read counter was decremented.
  • Part-file async write dispatch failures can leave buffered data permanently marked PB_PENDING.
  • A4AF cleanup can leave one side of the raw-pointer mirror linked when the client-side list and file-side A4AFsrclist are already out of sync.
  • Upload disk read completion sends packets through a raw socket after the upload-list lock has been released.
  • Temporary source deletion checks can assert on valid short-lived clients that were constructed with an initial request file.

Scope

  • Keep protocol behavior unchanged.
  • Prefer local runtime guards over broad ownership rewrites.
  • Add comments only where they explain why a lifetime guard exists.
  • Keep each fix in a granular app commit with scoped validation.

Acceptance Criteria

  • [x] Upload read completions keep file lifetime state valid until all file access is finished.
  • [x] Failed async write dispatch releases or errors every buffered item it removed from the flush queue.
  • [x] A4AF removal drops client-side links even when the file-side mirror is already missing the client.
  • [x] Upload socket sends fail closed when the socket is already on the delete path.
  • [x] Temporary source deletion checks distinguish externally linked clients from never-published reject-path clients.

Closure Evidence

App commits landed on emulebb/main:

  • 1a40187c BUG-126 hold upload reads through completion
  • 71bc84c1 BUG-126 release failed part writes
  • 427ea395 BUG-126 drop unsynced A4AF links
  • dca0c2c2 BUG-126 drop packets on deleting sockets
  • 038f97d9 BUG-126 distinguish temporary source deletes

Validation run during the implementation:

  • python -m emule_workspace build app --variant main --config Debug --platform x64 --build-output-mode ErrorsOnly
  • python -m emule_workspace build app --variant main --config Release --platform x64 --build-output-mode ErrorsOnly

The final Debug and Release build recaps returned success and reported 12 compiler warnings.