Skip to content

fix(linux): a service action through the helper waits up to 60 s, not the 10 s a read gets (#3029) - #3030

Merged
mgradwohl merged 2 commits into
mainfrom
fix/service-action-call-timeout-3029
Oct 26, 2026
Merged

mgradwohl merged 2 commits into
mainfrom
fix/service-action-call-timeout-3029

Conversation

@mgradwohl

@mgradwohl mgradwohl commented Oct 26, 2026 •

Copy link
Copy Markdown
Owner

Description

On Linux, a service action sent through tasksmack-helper had to finish within PkexecBroker::CALL_TIMEOUT (10 s), the same limit as a read. The helper waits up to UnitWait::timeout (10 s) for each state change, with bus calls of up to 2 s around each wait, and a restart is a stop and then a start. So a slow service outlasted the 10 s:

  • the UI said the action failed, although systemd carried it out;
  • call()'s closeLocked() ended the helper session, so the next read or action asked for the password again.

PkexecBroker::call() now waits SERVICE_ACTION_TIMEOUT (60 s) for a ServiceActionRequest, and CALL_TIMEOUT (10 s) for anything else. The new callTimeoutFor() picks between them. callIfIdle() is unchanged.

With the longer wait, a stop request has to reach the call. BrokeredServiceActions::retried() asked the helper with an empty std::stop_token{}, so a cancel, or closing TaskSmack, waited out the whole action. It now passes the action's token. A stopped wait returns ServiceActionResult::stopRequested(), in retried() and in runAuthorized(). FakeBroker fails a call whose token is stopped with "cancelled", as PkexecBroker does.

Windows is unaffected: service actions don't go through its helper.

Fixes #3029

PR Size

Small: 6 files, about 90 lines.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Build/CI improvement

Checklist

  • I have read the CONTRIBUTING guidelines
  • My code follows the project's coding standards
  • I have run clang-tidy and addressed any warnings
  • I have run clang-format on my changes
  • I have run pre-commit run --all-files or installed pre-commit hooks
  • I have added tests that prove my fix/feature works
  • All new and existing tests pass
  • I have updated documentation as needed

Testing

PkexecBrokerTest.AServiceActionWaitsLongerThanTheHelperCanTake derives the helper's worst case from SystemdBus::UnitWait and SystemdBus::CALL_TIMEOUT_USEC: two state changes, each a wait plus four bus calls. It checks that a restart's timeout is longer than that, and that other requests keep CALL_TIMEOUT. If either constant grows past the client's wait, the test fails.

BrokeredServiceActionsTest.AStopRequestEndsTheWaitForTheHelper checks that a stopped token reaches the helper's call and comes back as a cancelled result, from restart() and from runAuthorized().

cmake --build --preset debug -j 4
TASKSMACK_REQUIRE_DISPLAY=1 TASKSMACK_REQUIRE_SDBUS=1 xvfb-run -a env -u WAYLAND_DISPLAY ctest --preset debug -j 4   # all pass
clang-tidy-22 -p build/debug --header-filter="^$PWD/src/" src/Platform/Linux/PkexecBroker.cpp tests/Platform/test_BrokerServer.cpp

Additional Notes

Found in a review of the #2728 helper PRs (#3002, #3013). The mutex is held for the longer wait, so a process action queued behind a slow service action waits too, and the sampler's callIfIdle() reads report "busy" and skip that refresh, as they already do behind any call.

🤖 Generated with Claude Code

… the 10 s a read gets (#3029)

The helper waits up to 10 s for each state change around 2 s bus calls, and a
restart is a stop and then a start, so a slow service outlasted
PkexecBroker::CALL_TIMEOUT: the UI said the action failed though systemd carried
it out, and the timeout ended the helper session. call() now waits
SERVICE_ACTION_TIMEOUT for a ServiceActionRequest and CALL_TIMEOUT for anything
else.

Fixes #3029

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mgradwohl mgradwohl added this to the v0.10.0 milestone Oct 26, 2026
@mgradwohl mgradwohl added bug Something isn't working agent:WSL Owned by the Linux/WSL Claude session (bug-fix conveyor) labels Oct 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@mgradwohl
mgradwohl marked this pull request as ready for review October 26, 2026 09:43
@mgradwohl
mgradwohl enabled auto-merge (squash) October 26, 2026 09:43
…ion (#3029)

retried() asked the helper with an empty stop token, so with the 60 s wait a
cancel, or closing TaskSmack, waited out the whole action. It now passes the
action's token, and a stopped wait returns ServiceActionResult::stopRequested(),
as runAuthorized() now does too. FakeBroker fails a call whose token is stopped
with "cancelled", as PkexecBroker does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mgradwohl
mgradwohl disabled auto-merge October 26, 2026 09:57
@mgradwohl
mgradwohl enabled auto-merge (squash) October 26, 2026 09:57
@mgradwohl
mgradwohl merged commit 17cfb14 into main Oct 26, 2026
23 checks passed
@mgradwohl
mgradwohl deleted the fix/service-action-call-timeout-3029 branch October 26, 2026 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent:WSL Owned by the Linux/WSL Claude session (bug-fix conveyor) bug Something isn't working linux Platform testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] A service action through the Linux helper times out after 10 s and ends the helper session

1 participant