Skip to content

Conversation

pastamoe
Copy link

@pastamoe pastamoe commented Sep 3, 2025

This should resolve #317.

The actual fix:

  • add delay to socket-connection attempts, so we don't cause unnecessary CPU load (this required pulling up the cooldown-calculation logic).

Misc changes:

  • removed the "waiting for..." log, as it's kind of redundant with the log before the loop + the next change
  • socket connection errors are no longer ignored, instead a warning with the cause is logged. I think 'warning' is fitting here, as this error results in a retry by the loops that call this function
  • add more context to panics during set_uid/_pid calls. The original panic message is only useful with code at hand.
  • get_uid now returns an error in case loginuid is unset, instead of running into calls like set_uid with invalid values (which then cause a panic)

The misc changes are of course not relevant for the referenced issue, but they helped me a lot to understand what's wrong with my systemd service setup. If you're unhappy with those changes, I can of course drop them.

Side-Note regarding the "socket connection warning": It's kinda bad that the log-level down there is "dictated" by how the loop further up behaves. I think it'd be better to pass an (enriched) error up, and let the loop decide what to with it. But I didn't want to introduce more changes, also because this is my very first time looking into Rust.

The missing sleep results in a hot-loop, which causes unnecessary CPU load and log spam.

For details, see: waycrate#317
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Unexpected CPU load and log spam when swhkd doesn't detect swhks
2 participants