Skip to content

Fix suspend#4

Open
hboetes wants to merge 3 commits intomasterfrom
fix_suspend
Open

Fix suspend#4
hboetes wants to merge 3 commits intomasterfrom
fix_suspend

Conversation

@hboetes
Copy link
Copy Markdown
Owner

@hboetes hboetes commented Apr 6, 2026

More testing revealed that after suspending the fingerprint reader was still not working like it should. I had to enter a few random keystrokes and hit enter before being able to use the fingerprint reader.

@ink-splatters
Looking forward to your input on this PR.

hboetes added 3 commits April 6, 2026 19:31
CLOCK_MONOTONIC is frozen during suspend, causing all timers to appear
expired on resume. This makes loop_poll() calculate ms=0 and spin
without blocking, preventing the Wayland display fd from processing
events properly after resume.

CLOCK_BOOTTIME advances during suspend, keeping timer expiry times
correct across sleep/wake cycles.
Use mkstemp+rename to atomically create a per-user lockfile under
XDG_RUNTIME_DIR (falling back to /tmp), then flock it non-blocking.
A second instance exits immediately with a clear error message.

The mkstemp+rename approach is immune to symlink attacks, useful in
case /tmp is used; we hold the fd from mkstemp regardless of what is
at the final path, and O_NOFOLLOW is used for defence in depth. The
lock is released automatically by the kernel on process exit, making
stale locks impossible.
Three improvements to fingerprint behaviour across suspend/resume:

- Subscribe to logind's PrepareForSleep signal. On suspend, proactively
  stop the verify session and release the device before the USB stack
  resets it. On resume, the existing retry loop reclaims the device
  naturally.

- When claiming the device fails, attempt to release it first to evict
  any stale handle fprintd may be holding, then retry the claim.

- Add a 2 second backoff between failed claim attempts to avoid
hammering
  fprintd while it is restarting, and show "Fingerprint not yet
  available" in the indicator so the user knows what is happening.

Also refactor the device teardown logic into stop_and_release_device()
to avoid duplication between verify_result(), fingerprint_deinit() and
the new PrepareForSleep handler.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant