Skip to content

Workflow status is tracked in GitHub: https://github.com/emulebb/emulebb/issues/112. This local document is retained as an engineering spec/evidence record.

BUG-143 - Upload waiting queue retains clients for unavailable shared files

Summary

The upload waiting queue removes clients whose requested file is no longer shared only when later queue scans happen to visit those clients. Paths that make a complete shared file unavailable, such as deleting it from the Uploading list or a future per-file stopped-upload state, do not proactively remove waiting clients for the affected file.

Why This Matters

The stale entries are eventually pruned by admission, queue-rank, or statistics paths, but until then they can:

  • inflate waiting queue counts
  • keep stale rows visible in queue-related UI
  • add unnecessary scan work
  • make future "stopped shared file" behavior harder to reason about

Representative Sites

  • srchybrid/UploadQueue.cpp FindBestClientInQueue() lazily removes clients whose requested file is no longer in sharedfiles.
  • srchybrid/UploadQueue.cpp waiting-file statistics also prune stale client pointers while scanning.
  • srchybrid/UploadListCtrl.cpp active upload delete flow removes active upload clients for the file, then removes the shared file, but does not remove matching waiting-list clients.

Candidate Fix Direction

  • Add a focused upload-queue helper to remove or reject waiting clients by requested file hash.
  • Call that helper when a shared complete file is deleted, unshared, or marked stopped.
  • Keep client lifetime handling aligned with existing RemoveFromWaitingQueue semantics.
  • Refresh queue count and queue list UI once per affected file or batch.

Acceptance Criteria

  • [ ] When a shared complete file becomes unavailable for upload, matching waiting clients are removed or rejected promptly.
  • [ ] Queue count and queue list UI reflect the removal without waiting for a later admission scan.
  • [ ] Active upload removal and waiting queue removal are both handled for file delete and future stopped-upload transitions.
  • [ ] Client lifetime remains safe after removing waiting entries.
  • [ ] Stale waiting entries are not left behind for deleted or stopped files.

Validation

  • focused native tests for waiting-client removal by requested file hash
  • focused native tests for delete/unshare/stopped transitions
  • manual queue smoke with clients waiting for a file that is then deleted or stopped
  • x64 Debug and Release app builds before implementation commit