Skip to content

BUG-125 - Harden Client And Queue Lifetime Edges

Summary

Fix the concrete client and queue lifetime hazards found during the focused upload/download client review.

Findings To Address

  • CUpDownClient::TryToConnect() can enter the Kad buddy callback path with a buddy endpoint and no request file, then dereference m_reqfile.
  • CUploadQueue::DeleteAll() relies on a debug-only pending-I/O assertion before deleting upload queue entries.
  • A4AF source cleanup trusts raw client and part-file links without the stale pointer recovery used by normal source lists.
  • Per-client file-pointer caches can retain removed CPartFile * keys after a part file is stopped or deleted.

Scope

  • Keep protocol semantics unchanged.
  • Prefer local guards and cleanup over broad ownership rewrites.
  • Keep each fix in a granular commit with targeted validation.

Acceptance Criteria

  • [x] Kad buddy callback does not dereference a null request file.
  • [x] Upload queue shutdown does not delete entries with pending disk I/O.
  • [x] A4AF cleanup tolerates stale client/file links without dereferencing them.
  • [x] File removal purges auxiliary per-client caches that key on the removed part file pointer.
  • [x] Debug x64 and Release x64 app builds pass after the implementation.

Closure Evidence

App commits landed on emulebb/main:

  • c7567679 BUG-125 guard Kad callback file hash
  • db20c32d BUG-125 retain pending upload entries on shutdown
  • cd19a0e3 BUG-125 validate A4AF cleanup pointers
  • f6cbc7d5 BUG-125 purge part file client history

Validation run for each app slice:

  • python -m emule_workspace validate
  • 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