Skip to content

fix(volume): cancel the pending volume lookup's timeout when the lookup finishes - #2087

Merged
l0gicgate merged 2 commits into
lgse:mainfrom
pdwaldrop:fix/2069-cancel-volume-lookup-timeout
Nov 8, 2026
Merged

l0gicgate merged 2 commits into
lgse:mainfrom
pdwaldrop:fix/2069-cancel-volume-lookup-timeout

Conversation

@pdwaldrop

Copy link
Copy Markdown
Contributor

Description

A volume lookup (PendingVolumeLookup::start) spawned a 2 s timeout task that was never cancelled. After a lookup finished or was cancelled, the task stayed on the main context for about 2 s, keeping the lookup's state and cancellable alive until it fired and found nothing to do.

The lookup now keeps the task's JoinHandle and aborts it when the lookup finishes, and when it is cancelled with nothing waiting. A lookup that someone is waiting on keeps its timeout, since that is what ends it on a dead mount. The timeout path drops its own handle before calling finish, so the task does not abort itself. SourceId::remove() is not used, because it only searches the default context.

Visual evidence

N/A. Internal timer cleanup with no visible change.

How to test

  1. Run ./scripts/test-headless.py adapters::volume.
  2. To see the tests catch the bug, make PendingState::abort_timer in src/adapters/volume.rs only drop the handle and run ./scripts/test-headless.py lookup_regressions again.

Expected result: All volume tests pass. With the abort disabled, finished_lookup_leaves_no_timeout_task_holding_its_state and cancelled_lookup_leaves_no_timeout_task_holding_its_state fail with a reference count of 2 instead of 1.

Related issue

Closes #2069

…up finishes

The 2 s timeout task of a volume lookup stayed on the main context after the
lookup finished or was cancelled, keeping its state and cancellable alive
until it fired and found nothing to do. The lookup now keeps the task's
handle and aborts it when it finishes or is cancelled with nobody waiting.
The timer path detaches its own handle first so it does not abort itself.

Closes lgse#2069
@github-actions github-actions Bot added the fix label Nov 8, 2026
…s test

The finished-lookup case repeated the setup of
pending_lookup_finishes_promptly_without_reentering with an unbounded
busy loop, so assert the released state there instead. The cancelled
case waited a fixed 100 ms for the cancelled query callback to drop its
state reference; poll until it does, bounded below the 2 s timeout, so a
slow GIO worker pool cannot fail it.
@l0gicgate

Copy link
Copy Markdown
Contributor

Review and cleanup

Merged main: already up to date at 9fb7a36ad; no conflicts.

Review against the description and #2069. Every point of the suggested fix is implemented in src/adapters/volume.rs:

  • PendingState keeps the timer's JoinHandle; finish() aborts it, and cancel() aborts it only when nothing is waiting.
  • The timer path takes its own handle before calling finish, so it never aborts itself (dropping a glib JoinHandle detaches, it does not cancel).
  • SourceId::remove() is not used.

cancel() is only reached from Drop, so a wait() can never arrive after the timer was aborted. A lookup dropped while a drag-drop commit is waiting on it (file_drop_commit) keeps its timeout, which is what still ends it on a dead mount. No blockers found; code health of the touched files is unchanged from main (9.68 / 9.38 / 10.0).

Fixes pushed

  • e723b03fc test(volume): fold the finished-lookup timer check into the promptness test.
    • finished_lookup_leaves_no_timeout_task_holding_its_state repeated the setup of pending_lookup_finishes_promptly_without_reentering but used an unbounded busy loop. Its Rc::strong_count == 1 assertion now lives in that test.
    • cancelled_lookup_leaves_no_timeout_task_holding_its_state waited a fixed 100 ms for the cancelled GIO query to release its state reference, which could fail on a loaded runner. It now polls until the count drops, bounded at half of REMOTE_QUERY_TIMEOUT, so a missing abort still fails it.

Tests removed

  • adapters::volume::tests::lookup_regressions::finished_lookup_leaves_no_timeout_task_holding_its_state: duplicate setup; coverage owner: pending_lookup_finishes_promptly_without_reentering. The "How to test" step in the description that names it now applies to that test.

Validation

  • ./scripts/test-headless.py adapters::volume: 57 passed
  • ./scripts/test-headless.py ui::browser::clipboard (drop-classification callers): 43 passed
  • Mutation: with abort_timer changed to only drop the handle, both lookup_regressions timer tests fail (left: 2, right: 1); they pass with the fix.
  • ./scripts/quality.sh fmt, ./scripts/quality.sh clippy, git diff --check: clean
  • Not run: QA scenarios and a manual app check. This is an internal timer cleanup with no visible behaviour.

CI: all checks green on e723b03.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(volume): cancel the pending volume lookup's timeout when the lookup finishes

2 participants