fix(keyring): reuse one Secret Service session per process - #222
Merged
Merged
Conversation
Every credentials operation opened a fresh D-Bus connection and negotiated a new DH session. The recurrent gnome-keyring crash (issue #216, Ubuntu bug 2161749) is a race in that negotiation any client can trigger, so each new session is one more chance to hit it. Keep a single process-wide session, created lazily on first use and shared by get/set/delete/search/unlock/adopt. On a retryable failure (transport or stale session after a daemon restart) the cached session is dropped and the operation reconnects exactly once; domain errors (locked, missing item, dismissed prompt, unreadable secret) never reconnect. All access is serialized through a Mutex. The cache/reconnect policy lives in a pure helper with an injectable factory so it is testable without a Secret Service. Closes #221
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #221.
Every keyring operation (get/set/delete/search/unlock/adopt) opened a fresh D-Bus connection and negotiated a new DH session. The recurrent gnome-keyring crash investigated in #216 (Ubuntu bug 2161749) is a race in that session negotiation that any client can trigger, so each new session is another chance to hit it.
This keeps one process-wide session, created lazily on first use:
credentials.rsshare it, serializing access through a Mutex (engine threads and UI).The session is leaked by design (the process is long-lived and the crate ties collections/items to
&'a selfof the service, so a process-wide instance must be'staticanyway); a reconnect leaks one more instance, which is negligible.735->737 tests passing plus the usual known-flaky real-keyring pair, clippy -D warnings clean, fmt clean. No user-visible strings, no i18n changes.